Python pandas.Timestamp.fromordinal() Examples
The following are 6
code examples of pandas.Timestamp.fromordinal().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.Timestamp
, or try the search function
.
Example #1
Source File: test_timestamp.py From recruit with Apache License 2.0 | 6 votes |
def test_constructor_fromordinal(self): base = datetime(2000, 1, 1) ts = Timestamp.fromordinal(base.toordinal(), freq='D') assert base == ts assert ts.freq == 'D' assert base.toordinal() == ts.toordinal() ts = Timestamp.fromordinal(base.toordinal(), tz='US/Eastern') assert Timestamp('2000-01-01', tz='US/Eastern') == ts assert base.toordinal() == ts.toordinal() # GH#3042 dt = datetime(2011, 4, 16, 0, 0) ts = Timestamp.fromordinal(dt.toordinal()) assert ts.to_pydatetime() == dt # with a tzinfo stamp = Timestamp('2011-4-16', tz='US/Eastern') dt_tz = stamp.to_pydatetime() ts = Timestamp.fromordinal(dt_tz.toordinal(), tz='US/Eastern') assert ts.to_pydatetime() == dt_tz
Example #2
Source File: test_timestamp.py From vnpy_crypto with MIT License | 6 votes |
def test_constructor_fromordinal(self): base = datetime(2000, 1, 1) ts = Timestamp.fromordinal(base.toordinal(), freq='D') assert base == ts assert ts.freq == 'D' assert base.toordinal() == ts.toordinal() ts = Timestamp.fromordinal(base.toordinal(), tz='US/Eastern') assert Timestamp('2000-01-01', tz='US/Eastern') == ts assert base.toordinal() == ts.toordinal() # GH#3042 dt = datetime(2011, 4, 16, 0, 0) ts = Timestamp.fromordinal(dt.toordinal()) assert ts.to_pydatetime() == dt # with a tzinfo stamp = Timestamp('2011-4-16', tz='US/Eastern') dt_tz = stamp.to_pydatetime() ts = Timestamp.fromordinal(dt_tz.toordinal(), tz='US/Eastern') assert ts.to_pydatetime() == dt_tz
Example #3
Source File: test_timestamp.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_constructor_fromordinal(self): base = datetime(2000, 1, 1) ts = Timestamp.fromordinal(base.toordinal(), freq='D') assert base == ts assert ts.freq == 'D' assert base.toordinal() == ts.toordinal() ts = Timestamp.fromordinal(base.toordinal(), tz='US/Eastern') assert Timestamp('2000-01-01', tz='US/Eastern') == ts assert base.toordinal() == ts.toordinal() # GH#3042 dt = datetime(2011, 4, 16, 0, 0) ts = Timestamp.fromordinal(dt.toordinal()) assert ts.to_pydatetime() == dt # with a tzinfo stamp = Timestamp('2011-4-16', tz='US/Eastern') dt_tz = stamp.to_pydatetime() ts = Timestamp.fromordinal(dt_tz.toordinal(), tz='US/Eastern') assert ts.to_pydatetime() == dt_tz
Example #4
Source File: stressmodels.py From pastas with MIT License | 6 votes |
def simulate(self, p, tmin=None, tmax=None, freq=None, dt=1): tindex = date_range(tmin, tmax, freq=freq) if p[1] < tindex[0].toordinal(): tmin = tindex[0] else: tmin = Timestamp.fromordinal(int(p[1])) if p[2] >= tindex[-1].toordinal(): tmax = tindex[-1] else: tmax = Timestamp.fromordinal(int(p[2])) trend = tindex.to_series().diff() / Timedelta(1, "D") trend.loc[:tmin] = 0 trend.loc[tmax:] = 0 trend = trend.cumsum() * p[0] return trend
Example #5
Source File: test_timestamp.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_constructor_fromordinal(self): base = datetime(2000, 1, 1) ts = Timestamp.fromordinal(base.toordinal(), freq='D') assert base == ts assert ts.freq == 'D' assert base.toordinal() == ts.toordinal() ts = Timestamp.fromordinal(base.toordinal(), tz='US/Eastern') assert Timestamp('2000-01-01', tz='US/Eastern') == ts assert base.toordinal() == ts.toordinal() # GH#3042 dt = datetime(2011, 4, 16, 0, 0) ts = Timestamp.fromordinal(dt.toordinal()) assert ts.to_pydatetime() == dt # with a tzinfo stamp = Timestamp('2011-4-16', tz='US/Eastern') dt_tz = stamp.to_pydatetime() ts = Timestamp.fromordinal(dt_tz.toordinal(), tz='US/Eastern') assert ts.to_pydatetime() == dt_tz
Example #6
Source File: stressmodels.py From pastas with MIT License | 5 votes |
def simulate(self, p, tmin=None, tmax=None, freq=None, dt=1): tstart = Timestamp.fromordinal(int(p[-1]), freq="D") tindex = date_range(tmin, tmax, freq=freq) h = Series(0, tindex, name=self.name) h.loc[h.index > tstart] = 1 b = self.get_block(p[:-1], dt, tmin, tmax) npoints = h.index.size h = Series(data=fftconvolve(h, b, 'full')[:npoints], index=h.index, name=self.name, fastpath=True) return h