Python Forum

Full Version: datetime intervals - dataframe selection (via plotted data)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have plotted a Dataframe over a day and I would like to consider the negative parts (<0) marked in blue when x becomes positive for the first time and when it turns negative for the "first" time too but for a long time.
NB: intervals marked in black although negative cannot be taken into account.

[Image: IGaEo6C.png]

[Image: IGaEPob.png]

csv file: csv

here is my approach

x_start = 0
day_start = datetime.time(00,00,00)
day_end = datetime.time(23,59,59)
df_list = []

# Dataframe to List
'''df_list = [df.columns.values.tolist()] + df.values.tolist()
print(df_list)'''

for col in df:
    if df[col] in range (day_start, day_end):
       # Dataframe where x is negative 
       df_neg = df[(df<0).all(1)]

# ...

 # Honestly I dont know how to continue ... but I'm trying :)
   
thank you in advance