Reputation: 7273
I am using this dataset:
https://gist.github.com/JafferWilson/2c468679fa66c04c08a0ca624ca92d8f
What I want to achieve is:
I have tried to load the values from the csv using the pandas dataframe as:
import pandas as pd
df = pd.read_csv("EURM1.csv")
But I don't know how to sort the data in the fashion I want. I tried using the startdate
and enddate
, but they are of no use to me.
Please help me to get the data in the form I want it.
Upvotes: 1
Views: 97
Reputation: 24201
Once you have converted the column to datetime, you can easily perform a conditional operation on it as per your logic:
df["date"] = pd.to_datetime(df["date"], format="%Y.%m.%d %H:%M:%S")
df = df.loc[~((df["date"].dt.weekday_name == "Monday") # Excludes Mondays before 2am
& (df["date"].dt.hour < 2))
& ~((df["date"].dt.weekday_name == "Friday") # Excludes Fridays after 10pm
& (df["date"].dt.hour >= 22))]
Upvotes: 3