本文整理匯總了Python中pandas.Timestamp.max方法的典型用法代碼示例。如果您正苦於以下問題:Python Timestamp.max方法的具體用法?Python Timestamp.max怎麽用?Python Timestamp.max使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.Timestamp
的用法示例。
在下文中一共展示了Timestamp.max方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_out_of_bounds_value
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def test_out_of_bounds_value(self):
one_us = np.timedelta64(1).astype('timedelta64[us]')
# By definition we can't go out of bounds in [ns], so we
# convert the datetime64s to [us] so we can go out of bounds
min_ts_us = np.datetime64(Timestamp.min).astype('M8[us]')
max_ts_us = np.datetime64(Timestamp.max).astype('M8[us]')
# No error for the min/max datetimes
Timestamp(min_ts_us)
Timestamp(max_ts_us)
# One us less than the minimum is an error
with pytest.raises(ValueError):
Timestamp(min_ts_us - one_us)
# One us more than the maximum is an error
with pytest.raises(ValueError):
Timestamp(max_ts_us + one_us)
示例2: __init__
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def __init__(self, stress, rfunc, name, up=True, cutoff=0.999,
settings=None, metadata=None, meanstress=None):
if isinstance(stress, list):
stress = stress[0] # TODO Temporary fix Raoul, 2017-10-24
stress = TimeSeries(stress, settings=settings, metadata=metadata)
if meanstress is None:
meanstress = stress.series.std()
StressModelBase.__init__(self, rfunc, name, stress.series.index.min(),
stress.series.index.max(), up, meanstress,
cutoff)
self.freq = stress.settings["freq"]
self.stress = [stress]
self.set_init_parameters()
示例3: test_max_valid
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def test_max_valid(self):
# Ensure that Timestamp.max is a valid Timestamp
Timestamp(Timestamp.max)
示例4: test_asm8
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def test_asm8(self):
np.random.seed(7960929)
ns = [Timestamp.min.value, Timestamp.max.value, 1000]
for n in ns:
assert (Timestamp(n).asm8.view('i8') ==
np.datetime64(n, 'ns').view('i8') == n)
assert (Timestamp('nat').asm8.view('i8') ==
np.datetime64('nat', 'ns').view('i8'))
示例5: test_to_datetime_bijective
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def test_to_datetime_bijective(self):
# Ensure that converting to datetime and back only loses precision
# by going from nanoseconds to microseconds.
exp_warning = None if Timestamp.max.nanosecond == 0 else UserWarning
with tm.assert_produces_warning(exp_warning, check_stacklevel=False):
assert (Timestamp(Timestamp.max.to_pydatetime()).value / 1000 ==
Timestamp.max.value / 1000)
exp_warning = None if Timestamp.min.nanosecond == 0 else UserWarning
with tm.assert_produces_warning(exp_warning, check_stacklevel=False):
assert (Timestamp(Timestamp.min.to_pydatetime()).value / 1000 ==
Timestamp.min.value / 1000)
示例6: set_init_parameters
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def set_init_parameters(self):
self.parameters = self.rfunc.get_init_parameters(self.name)
tmin = Timestamp.min.toordinal()
tmax = Timestamp.max.toordinal()
tinit = self.tstart.toordinal()
self.parameters.loc[self.name + "_tstart"] = (tinit, tmin, tmax,
False, self.name)
示例7: datetime_column
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def datetime_column(
name,
min_datetime=Timestamp.min,
max_datetime=Timestamp.max,
non_nullable=False,
unique=False,
ignore_missing_vals=False,
is_required=None,
):
'''
Simple constructor for PandasColumns that expresses datetime constraints on 'datetime64[ns]' dtypes.
Args:
name (str): Name of the column. This must match up with the column name in the dataframe you
expect to receive.
min_datetime (Optional[Union[int,float]]): The lower bound for values you expect in this column.
Defaults to pandas.Timestamp.min.
max_datetime (Optional[Union[int,float]]): The upper bound for values you expect in this column.
Defaults to pandas.Timestamp.max.
non_nullable (Optional[bool]): If true, this column will enforce a constraint that all values in the column
ought to be non null values.
unique (Optional[bool]): If true, this column will enforce a uniqueness constraint on the column values.
ignore_missing_vals (Optional[bool]): A flag that is passed into most constraints. If true, the constraint will
only evaluate non-null data. Ignore_missing_vals and non_nullable cannot both be True.
is_required (Optional[bool]): Flag indicating the optional/required presence of the column.
If the column exists the validate function will validate the column. Default to True.
'''
return PandasColumn(
name=check.str_param(name, 'name'),
constraints=[
ColumnDTypeInSetConstraint({'datetime64[ns]'}),
InRangeColumnConstraint(
min_datetime, max_datetime, ignore_missing_vals=ignore_missing_vals
),
]
+ _construct_keyword_constraints(
non_nullable=non_nullable, unique=unique, ignore_missing_vals=ignore_missing_vals
),
is_required=is_required,
)
示例8: add_stressmodel
# 需要導入模塊: from pandas import Timestamp [as 別名]
# 或者: from pandas.Timestamp import max [as 別名]
def add_stressmodel(self, stressmodel, replace=False):
"""Add a stressmodel to the main model.
Parameters
----------
stressmodel: pastas.stressmodel or list of pastas.stressmodel
instance of a pastas.stressmodel class. Multiple stress models
can be provided (e.g., ml.add_stressmodel([sm1, sm2]) in one call.
replace: bool, optional
force replace the stressmodel if a stressmodel with the same name
already exists. Not recommended but useful at times. Default is
False.
Notes
-----
To obtain a list of the stressmodel names, type:
>>> ml.get_stressmodel_names()
Examples
--------
>>> sm = ps.StressModel(stress, rfunc=ps.Gamma, name="stress")
>>> ml.add_stressmodel(sm)
To add multiple stress models at once you can do the following:
>>> sm1 = ps.StressModel(stress, rfunc=ps.Gamma, name="stress1")
>>> sm1 = ps.StressModel(stress, rfunc=ps.Gamma, name="stress2")
>>> ml.add_stressmodel([sm1, sm2])
See Also
--------
pastas.stressmodels
"""
# Method can take multiple stressmodels at once through args
if isinstance(stressmodel, list):
for sm in stressmodel:
self.add_stressmodel(sm)
elif (stressmodel.name in self.stressmodels.keys()) and not replace:
self.logger.error("The name for the stressmodel you are trying "
"to add already exists for this model. Select "
"another name.")
else:
self.stressmodels[stressmodel.name] = stressmodel
self.parameters = self.get_init_parameters(initial=False)
if self.settings["freq"] is None:
self._set_freq()
stressmodel.update_stress(freq=self.settings["freq"])
# Check if stress overlaps with oseries, if not give a warning
if (stressmodel.tmin > self.oseries.series.index.max()) or \
(stressmodel.tmax < self.oseries.series.index.min()):
self.logger.warning("The stress of the stressmodel has no "
"overlap with ml.oseries.")
self.check_stressmodel_compatibility()