4 ms·
I know pandas is a bit meaty for a date time library if you don't already use it but their Timestamp class is awesome. String parsing is a breeze, offsets and t
by abuckenheimer 10y ago
I know pandas is a bit meaty for a date time library if you don't already use it but their Timestamp class is awesome. String parsing is a breeze, offsets and timezones are easy and then there's a ton of support for time series.
In [34]: pd.Timestamp('2016-08') == pd.Timestamp('2016.08') == pd.Timestamp('2016/08') == pd.Timestamp('08/2016')
Out[34]: True
In [38]: pd.Timestamp('2016') == pd.Timestamp(datetime.datetime(2016,1,1))
Out[38]: True
In [49]: pd.Timestamp('2016') + pd.offsets.MonthOffset(months=7) == pd.Timestamp('2016-08')
Out[49]: True
In [52]: pd.Timestamp.now()
Out[52]: Timestamp('2016-08-17 08:01:07.576323')
In [53]: pd.Timestamp.now() + pd.offsets.MonthBegin(normalize=True)
Out[53]: Timestamp('2016-09-01 00:00:00')
see http://pandas.pydata.org/pandas-docs/stable/timeseries.html http://pandas.pydata.org/pandas-docs/stable/timeseries.html for more examples
- jonathanpoulter 10y agoI also really like the Timestamp class, are the obvious reasons not to use it?
- djrobstep 10y agoHaving pandas as a dependency?
- jonathanpoulter 10y agoThat doesn't seem like a terrible dependency, is that the only reason?