Answers for "split date into month and year in pandas"

0

how to separate year from datetime column in python

df['year'] = pd.DatetimeIndex(df['ArrivalDate']).year
df['month'] = pd.DatetimeIndex(df['ArrivalDate']).month
Posted by: Guest on June-04-2021
-1

pandas splitting the data based on the day type

day['hour'] = day['date_time'].dt.hour
bussiness_days = day.copy()[day['dayofweek'] <= 4] # 4 == Friday
weekend = day.copy()[day['dayofweek'] >= 5] # 5 == Saturday
by_hour_business = bussiness_days.groupby('hour').mean()
by_hour_weekend = weekend.groupby('hour').mean()

print(by_hour_business['traffic_volume'])
print(by_hour_weekend['traffic_volume'])
Posted by: Guest on August-18-2021

Code answers related to "split date into month and year in pandas"

Python Answers by Framework

Browse Popular Code Answers by Language