nonetype

pandas combine two columns with null values

 ̄綄美尐妖づ 提交于 2020-12-28 06:52:53
问题 I have a df with two columns and I want to combine both columns ignoring the NaN values. The catch is that sometimes both columns have NaN values in which case I want the new column to also have NaN. Here's the example: df = pd.DataFrame({'foodstuff':['apple-martini', 'apple-pie', None, None, None], 'type':[None, None, 'strawberry-tart', 'dessert', None]}) df Out[10]: foodstuff type 0 apple-martini None 1 apple-pie None 2 None strawberry-tart 3 None dessert 4 None None I tried to use fillna

pandas combine two columns with null values

泪湿孤枕 提交于 2020-12-28 06:50:12
问题 I have a df with two columns and I want to combine both columns ignoring the NaN values. The catch is that sometimes both columns have NaN values in which case I want the new column to also have NaN. Here's the example: df = pd.DataFrame({'foodstuff':['apple-martini', 'apple-pie', None, None, None], 'type':[None, None, 'strawberry-tart', 'dessert', None]}) df Out[10]: foodstuff type 0 apple-martini None 1 apple-pie None 2 None strawberry-tart 3 None dessert 4 None None I tried to use fillna

pandas combine two columns with null values

痞子三分冷 提交于 2020-12-28 06:48:05
问题 I have a df with two columns and I want to combine both columns ignoring the NaN values. The catch is that sometimes both columns have NaN values in which case I want the new column to also have NaN. Here's the example: df = pd.DataFrame({'foodstuff':['apple-martini', 'apple-pie', None, None, None], 'type':[None, None, 'strawberry-tart', 'dessert', None]}) df Out[10]: foodstuff type 0 apple-martini None 1 apple-pie None 2 None strawberry-tart 3 None dessert 4 None None I tried to use fillna

Pandas read_sql_query returning None for all values in some columns

岁酱吖の 提交于 2020-12-26 08:11:18
问题 I am using pandas read_sql_query to read data from a MySQL database table into a pandas dataframe. Some columns in this table have all NULL values. For those columns the pandas dataframe contains None in every row. For all other columns the dataframe contains NaN where there was a NULL value. Can anyone explain why None is returned for the all NULL columns? And how do I make sure I have all NaNs, hopefully without doing manual conversions? I should add that two of the columns causing this

TypeError: coercing to Unicode, need string or buffer, NoneType found

北城余情 提交于 2020-12-08 10:26:36
问题 Currently writing a function for a program and one component is to search whether a single variables are being used within a python file. FUNCTION: def SINGLE_CHAR_VAR(python_filename): file = open(python_filename) lines = [0] SINGLE_CHAR_VAR = [] for line in file: stripped = line.strip('\n\r') lines.append(stripped) from utils import vars_indents variable_list = (vars_indents(python_filename))[0] for i in range(1, len(variable_list)): if len(variable_list[i][0][0]) == 1: SINGLE_CHAR_VAR

Python error: 'NoneType' object has no attribute 'find_all'

僤鯓⒐⒋嵵緔 提交于 2020-11-28 02:40:30
问题 I'm adapting a web scraping program from, http://danielfrg.com/blog/2013/04/01/nba-scraping-data/#disqus_thread, to scrape ESPN for baseball data into a CSV. However when I run the second piece of code to write a csv of games I get the 'NoneType' object has no attribute 'find_all' error, from the following section of code for index, row in teams.iterrows(): _team, url = row['team'], row['url'] r = requests.get(BASE_URL.format(row['prefix_1'], year, row['prefix_2'])) table = BeautifulSoup(r

Python error: 'NoneType' object has no attribute 'find_all'

孤街醉人 提交于 2020-11-28 02:40:17
问题 I'm adapting a web scraping program from, http://danielfrg.com/blog/2013/04/01/nba-scraping-data/#disqus_thread, to scrape ESPN for baseball data into a CSV. However when I run the second piece of code to write a csv of games I get the 'NoneType' object has no attribute 'find_all' error, from the following section of code for index, row in teams.iterrows(): _team, url = row['team'], row['url'] r = requests.get(BASE_URL.format(row['prefix_1'], year, row['prefix_2'])) table = BeautifulSoup(r