I have looked at other solutions online but none of them work on my dataframe.
I want to get the exact location of a specific datetime object but this code produces this keyerror KeyError: '2018-1-31'
import pandas as pd
data=pd.DataFrame()
dti = pd.date_range("2018-01-01", periods=10, freq="M")
data['dti']=dti
print((data['dti'].loc['2018-1-31'])) # it should print 0 since this date is in the first row