Python Forum
datetime intervals - dataframe selection (via plotted data) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: datetime intervals - dataframe selection (via plotted data) (/thread-22408.html)



datetime intervals - dataframe selection (via plotted data) - karlito - Nov-12-2019

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