Pavan Ramapragada
Pavan Ramapragada

Reputation: 15

Selecting rows in a DataFrame based on Time of the day?

I have a DataFrame with Datetime as my index_col. This data is for 14 days. I want to create two different DataFrames based on the time of day: data between 6 am and 18 pm of all days as one df and data between 18 pm and 6 am of all days in another df. How to extract?

Below is my Dataframe screenshot

enter image description here

Upvotes: 1

Views: 71

Answers (1)

M_S_N
M_S_N

Reputation: 2810

try using

for df1

df1=df.between_time('06:00', '18:00')

for df2

df2=df.between_time('18:00', '06:00')

more about it here

Upvotes: 4

Related Questions