简体   繁体   中英

extract datetime obj value from pandas Series (single row)

I have same issue as describe here link but this time with a datetime object.

Using .values converts the datetime object to something like 2011-02-28T19:00:00.000000000-0500 .

Prior to the conversion the datetime was 2011-03-01

What is the proper way to do what I want to do?

由于高精度的datetime64的[NS]值,如果你只是对日期感兴趣的话可以calll dt.date之前调用.values

p0_cost = (cost_df['price1'][cost_df['date']==p0] - cost_df['price2'][cost_df['date']==p0]).dt.date.values[0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM