Feel free to critique. Uploading in case some of it is useful, or could be improved…
Didn’t flesh it out - but it’s not hard to do a function that returns the mapping dict to go from camelCase to snake_case. Put in a URL.
What may be useful is the get_mean function that, given a df and one column name and values (because user might employ some filtering so values are not ALL values for that column , ) and another column name, will return a dict with the values and mean values for the “other” column.
def get_mean( df, index, values, col ) :
""" DataFrame, string, list of strings, string --> pd.Series object """
# Given the Dataframe, index name , value-list and column name,
# will get all the rows for the index equal to specified values and then
# return the mean from the column for each of those rows
mean_dict = {}
for value in values :
mean_dict[ value ] = df.loc[ df[index] == value , col ].mean()
return pd.Series( mean_dict )
https://app.dataquest.io/m/294/guided-project%3A-exploring-ebay-car-sales-data/9/next-steps
Basics.ipynb (119.9 KB)