Home > Blockchain >  Extract certain dataframes of lists of dataframes
Extract certain dataframes of lists of dataframes

Time:10-24

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.

CodePudding user response:

Try:

Collection = [subdf for subdf in subdfs if subdf.iloc[0, subdf.columns.get_loc('Zeitpunkt')].hour == 12]

CodePudding user response:

It worked with:

Collection = [subdfs for subdfs in subdfs if subdfs.iloc[0, 1].hour == 12]
  • Related