简体   繁体   English

是pandas.timestamp python datetime吗?

[英]Is pandas.timestamp python datetime?

I was working on time submodule of astropy. 我正在研究astropy的时间子模块。 It can parse python datetime objects. 它可以解析python datetime对象。

When I pass a pandas.Timestamp object astropy.time.Time thinks it's a datetime object. 当我传递pandas.Timestamp对象astropy.time.Time认为它是一个datetime对象时。

Tracking down the issue, I found this. 找出问题所在,发现了这一点。

>>> t = pandas.Timestamp('2018-01-01')
>>> isinstance(t, datetime.datetime)
True

My question is, why is isinstance returning True ? 我的问题是,为什么isinstance返回True

because it inherits from datetime.datetime 因为它继承自datetime.datetime

class _Timestamp(__datetime.datetime):

so it is an instance of a datetime.datetime ... 所以它是datetime.datetime一个实例...

TimeStamp is the pandas equivalent of python's Datetime and is interchangable with it in most cases. TimeStamp与python的Datetime等效,在大多数情况下可以互换。

See pandas.Timestamp documentation 请参阅pandas.Timestamp文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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