Extract certain dataframes of lists of dataframes

Question:

I have a list of dataframes. Each is build up as followed:
Dataframe

No i want to extract the dataframes beginning at a certain time.

Collection=[]
for i in range(len(subdfs)):
   if any(subdfs[i]['Zeitpunkt'][subdfs[i]['Zeitpunkt'].dt.hour.eq(12)]):
      Collection.append(subdfs[i]['Zeitpunkt'])

With this code i am able to extract every dataframe where the hour 12 appears. But i only want the dataframes where the hour 12 is in the first row.

Asked By: luscgu00

||

Answers:

Try:

Collection = [subdf for subdf in subdfs if subdf.iloc[0, subdf.columns.get_loc('Zeitpunkt')].hour == 12]
Answered By: Nuri Taş

It worked with:

Collection = [subdfs for subdfs in subdfs if subdfs.iloc[0, 1].hour == 12]
Answered By: luscgu00
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.