May-14-2018, 09:01 AM
(This post was last modified: May-14-2018, 09:01 AM by Jack_Sparrow.)
Hi guys,
I have this column:
Start Time
0 2017-05-29 18:36:27
1 2017-06-12 19:00:33
2 2017-02-13 17:02:02
3 2017-04-24 18:39:45
4 2017-01-26 15:36:07
I want to calculate the Most Frequent Months of Travel.
There are my steps:
What is the right if statement here?
Thank you!
I have this column:
Start Time
0 2017-05-29 18:36:27
1 2017-06-12 19:00:33
2 2017-02-13 17:02:02
3 2017-04-24 18:39:45
4 2017-01-26 15:36:07
I want to calculate the Most Frequent Months of Travel.
There are my steps:
#transform strart date into datetime df['Start Time'] = pd.to_datetime(df['Start Time']) #generate new column with months df['month'] = df['Start Time'].dt.month #calculate the Frequent Months of Travel popular_month = df['month'].mode()[0] #rename int into str df1['month_name']: if popular_month = 1: return 'January' elif popular_month = 6: return 'June' else: return 'Others' print('\nThe Most Frequent Months of Travel:', month_name)I have a problem with rename month as an int (1, 2, 3, etc.) into str (January, February etc.)
What is the right if statement here?
Thank you!