Python pandas select rows by list of dates Python pandas select rows by list of dates pandas pandas

Python pandas select rows by list of dates


You can use index.isin() method to create a logical index for subsetting:

df[df.index.isin(myDates)]

enter image description here


Convert your entry into a DateTimeIndex:

df.loc[pd.to_datetime(myDates)]                   A         B         C         D2013-01-02 -0.047710 -1.827593 -0.944548 -0.1494602013-01-04  1.437924  0.126788  0.641870  0.1986642013-01-06  0.408820 -1.842112 -0.287346  0.071397