import pandas as pd df = pd.read_csv("nps.csv", parse_dates=["event_date"]) df['yearmonth'] = df['event_date'].dt.strftime('%Y%m') df['category'] = df['score'].apply(categorize) nps = df.pivot_table(index = 'yearmonth', columns = 'category', aggfunc = 'size') nps['total_responses'] = nps.sum(axis = 1) nps['nps'] = (nps['Promoter']-nps['Detractor'])/nps['total_responses'] nps['nps'] = (nps['nps']*100).astype(int)
What I expected to happen:
Create yearmonth column in format yyyymm using dt.strftime(’%Y%m’)
What actually happened:
column successfully created in correct format, and final results match the ‘expected’ results for both df and nps, but the autograder says both are incorrect.
Please let me know if this is a problem with the autograder or why my code returns as incorrect here - perhaps I am missing something conceptually or in the middle of the dataframes there’s something that’s off that I can’t view.