Why creating DataFrame throws Error on DQ Environment

Guided Project: Investigating Fandango Movie Ratings

This code works fine in my local Jupyter

My Code:

summary_2015_16 = dict()

summary_2015_16['mean'] = [orig_ratings_2015['Fandango_Stars'].mean(),new_ratings_2016['fandango'].mean()]
summary_2015_16['median'] = [orig_ratings_2015['Fandango_Stars'].median(), new_ratings_2016['fandango'].median()]
summary_2015_16['mode'] = [orig_ratings_2015['Fandango_Stars'].mode().iloc[0], new_ratings_2016['fandango'].mode().iloc[0]] 

df_sum_2015_16 = pd.DataFrame.from_dict(summary_2015_16, orient='index',columns=['2015','2016'])

What I expected to happen (screenshot from my environment):

What actually happened (screenshot from DQ environment):

TypeErrorTraceback (most recent call last)
<ipython-input-21-fe0a4a23356c> in <module>()
      5 summary_2015_16['mode'] = [orig_ratings_2015['Fandango_Stars'].mode().iloc[0], new_ratings_2016['fandango'].mode().iloc[0]]
----> 7 df_sum_2015_16 = pd.DataFrame.from_dict(summary_2015_16, orient='index', columns=['2015','2016'])
      8 df_sum_2015_16

TypeError: from_dict() got an unexpected keyword argument 'columns'

Hello Maksym,

pandas.DataFrame.from_dict() added the columns= parameter in version ‘0.23.0’ as can be seen in the documentation.

If you run pd.__version__ in the DQ environment you will most likely get a printout that reads '0.22.0'.
What you can do is remove columns=['2015','2016'] as parameter and set columns separately.

df_sum_2015_16.columns = ['2015','2016']
1 Like

Thanks Ivan - true - my version is ‘1.0.5’