Problem (and solution) to a pandas join issue in data analysis tutorial
----- UPDATE: after further experimentation, I found out that the problem is that the dataframe returned by Quandl.get() does not have proper column names (they are just "values" ). Thus the data for each state has same name (value). I found that loop works if I set the column name manually: df = Quandl.get(query, authtoken=api_key) df.columns = [abbv] ### This is the fix ###
In the video they somehow get the proper column names automatically. ------ Hi,
I was going through the data analysis tutorial where you talk about how to join together to pandas dataframes, and I think there might have been some change in the pandas default behavior or something because the example code does not work as it currently is. For example, in the 7th tutorial the code
main_df = main_df.join(df)
generates the following error: ValueError: columns overlap but no suffix specified: Index([u'Value'], dtype='object')
after a lot of hair pulling I found that I can get it running like this: main_df = main_df.join(df, lsuffix=abbv)
where abbv is the US state abbreviation (it just needs to be some text for the suffix)
or maybe my pandas/spyder is somehow misconfigured.
You must be logged in to post. Please login or register an account.
I am having this problem as well...
-ABQJuan 9 years ago
You must be logged in to post. Please login or register an account.
Sorry I didnt see the solution previously
-ABQJuan 9 years ago
You must be logged in to post. Please login or register an account.
Thanks, that helped a lot! I was stuck at data analysis part 4 and then again at part 7, but this seemed to help.
-odevaan 8 years ago
You must be logged in to post. Please login or register an account.
I was completely stumped by this issue. I initially arrived at the same "lsuffix=abbv" solution but I didn't understand why it worked. Thanks for the explanation on why "df.columns = [abbv]" works!
-dynera 8 years ago
You must be logged in to post. Please login or register an account.
What did you learned in Part 3? Renaming columns :). The problem is, that in every DataFrame there is a column named Value. You can rename this column easily
df.rename(columns={'Value':abbv}, inplace=True)
-Sceada 8 years ago
You must be logged in to post. Please login or register an account.
Also was stuck on that one. Thanks basalganglia for solving it. Pulled some hair out searching around and trying to fix it.
So hey, Harrison, how come it just worked on your YT video and we could not reproduce it?
Great tutorial so far. Eating it up man.
-salvideoguy 8 years ago
You must be logged in to post. Please login or register an account.