Select DataFrame rows between two dates

前端 未结 10 693
挽巷
挽巷 2020-11-22 03:14

I am creating a DataFrame from a csv as follows:

stock = pd.read_csv(\'data_in/\' + filename + \'.csv\', skipinitialspace=True)

The DataFra

10条回答
  •  名媛妹妹
    2020-11-22 03:56

    I feel the best option will be to use the direct checks rather than using loc function:

    df = df[(df['date'] > '2000-6-1') & (df['date'] <= '2000-6-10')]
    

    It works for me.

    Major issue with loc function with a slice is that the limits should be present in the actual values, if not this will result in KeyError.

提交回复
热议问题