2018-10-09 10:00:00 7528000.0
2018-10-09 11:00:00 7531000.0
2018-10-09 12:00:00 7532000.0
2018-10-10 13:00:00 7540000.0
2018-10-10 14:00:00 7550000.0
From these series extracted from data frames,
dateback2 = back[1].index.values
print('today date', dateback2)
If you do, the result is
Today Date ['2018-10-09T11:0000.0000000']
It comes out like this.
Remove the back part and extract the 2018-10-09 only I want to search for another data frame index, what should I do?
date2 = dateback2.item()
print('today' date2)
Hani
Today's date 15393492000000000
It comes at this price.
date2 = dateback2.strftime("%Y%m%d")
print('today' date2)
An error appears.
I'd like to extract only the date of 2018-10-09 and search for that date in another data frame.
python datetime
The conversion is possible as below.
>>> df
0 2018-01-01
1 2018-01-04
2 2018-01-05
3 2018-01-06
dtype: datetime64[ns]
>>> df.dt.strftime("%Y%m%d")
0 20180101
1 20180104
2 20180105
3 20180106
dtype: object
>>> df.dt.strftime("%Y-%m-%d")
0 2018-01-01
1 2018-01-04
2 2018-01-05
3 2018-01-06
dtype: object
© 2024 OneMinuteCode. All rights reserved.