I have a pandas data frame that I created as follows:
dates = pd.date_range('12-01-2020','12-10-2020')
my_df = pd.DataFrame(dates, columns = ['Date'])
So this gives
Date
0 2020-12-01
1 2020-12-02
2 2020-12-03
3 2020-12-04
4 2020-12-05
5 2020-12-06
6 2020-12-07
7 2020-12-08
8 2020-12-09
9 2020-12-10
My question is very elementary: What is the correct function to use for returning the index of a given date? I have tried my_df['Date'].index('2020-12-05'), expecting to get 4, but instead I got the following error: 'RangeIndex' object is not callable. I also tried
d = pd.TimeStamp('12-05-2020' + '00:00:00')
my_df['Date'].index(d)
but I got the same error...I'm confused because I've used .index successfully in similar situations, such as on lists with integers. Any help would be appreciated.