May-15-2018, 05:41 PM
(This post was last modified: May-15-2018, 05:41 PM by Jack_Sparrow.)
Hi there
I have followed error:
It is all about this line: if weekday != 'all': and this one: if month != 'all':
in this statement:
How can I fix this?
I have followed error:
1 |
Indentationerror: unindent does not match any outer indentation level |
It is all about this line: if weekday != 'all': and this one: if month != 'all':
in this statement:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
df = pd.read_csv(CITY_DATA[city]) def main(): while True : city, month, weekday #For weekday df = load_data(city, month, weekday) # TO DO: display the most common month #convert start time into datetime df[ 'Start Time' ] = pd.to_datetime(df[ 'Start Time' ]) #create a month column df[ 'month' ] = df[ 'Start Time' ].dt.month df[ 'day_of_week' ] = df[ 'Start Time' ].dt.weekday_name if weekday ! = 'all' : # filter by day of week to create the new dataframe df = df[df[ 'day_of_week' ] = = weekday.title()] # filter by month if applicable if month ! = 'all' : # use the index of the months list to get the corresponding int months = [ 'January' , 'February' , 'March' , 'April' , 'May' , 'June' ] month = months.index(month) + 1 if __name__ = = "__main__" : main() |