Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PandasError: DataFrame constructor not properly called #6

Closed
akelai opened this issue Mar 1, 2020 · 1 comment
Closed

PandasError: DataFrame constructor not properly called #6

akelai opened this issue Mar 1, 2020 · 1 comment

Comments

@akelai
Copy link

akelai commented Mar 1, 2020

In the "Ingest_Data_Into_PostgreSQL.ipynb" jupyter notebook, the last command (26) does not work and gives a python error.

Command:

Finally, we want to label the 5 types of weather data noted above with human-readable names. We create a dictionary mapping each label to its description, create a Data Frame from that, and write it to the database

weather_type_dict = {'PRCP': 'Precipitation', 'SNOW': 'Snowfall', 'SNWD': 'Snow Depth', 
                     'TMAX': 'Maximum temperature', 'TMIN': 'Minimum temperature'}
weather_type_df = DataFrame(weather_type_dict.items(), columns=['weather_type', 'weather_description'])
description_table_name = 'weather_types'
weather_type_df.to_sql(description_table_name, conn, index_label='id')

Error when executed:

...
----> 3 weather_type_df = DataFrame(weather_type_dict.items(), columns=['weather_type', 'weather_description'])
...
PandasError: DataFrame constructor not properly called!
@akelai
Copy link
Author

akelai commented Mar 1, 2020

Fixed: it's because for Python3, the 3rd line has to be

weather_type_df = pd.DataFrame(list(weather_type_dict.items()), columns=['weather_type', 'weather_description'])

@akelai akelai closed this as completed Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant