I have this pandas dataframe:
I need to consider only the first "up" of the day.
So My goal is to have this dataframe:
This is some working code:
import pandas as pd
from datetime import datetime
tbl = {"date" :["2022-02-27", "2022-02-27", "2022-02-27", "2022-02-28", "2022-02-28","2022-02-
28"],
"direction" : ["up", "up", "NaN", "NaN", "up", "up"]}
df = pd.DataFrame(tbl)
df = df.replace('NaN', float('nan'))
pd.to_datetime(df['date'], format='%Y-%m-%d')
df.sort_values(by = "date", inplace=True)
Any ideas?

