本文整理汇总了Python中pandas.series方法的典型用法代码示例。如果您正苦于以下问题:Python pandas.series方法的具体用法?Python pandas.series怎么用?Python pandas.series使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas
的用法示例。
在下文中一共展示了pandas.series方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def train(self, x, drop=None):
"""
Train scale
Parameters
----------
x: pd.series| np.array
a column of data to train over
A discrete range is stored in a list
"""
if not len(x):
return
na_rm = (not self.na_translate)
self.range.train(x, drop, na_rm=na_rm)
示例2: hpat_pandas_series_str
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def hpat_pandas_series_str(self):
"""
Pandas Series attribute :attr:`pandas.Series.str` implementation
.. only:: developer
Test: python -m sdc.runtests sdc.tests.test_hiframes.TestHiFrames.test_str_get
"""
_func_name = 'Attribute str.'
if not isinstance(self, SeriesType):
raise TypingError('{} The object must be a pandas.series. Given: {}'.format(_func_name, self))
if not isinstance(self.data.dtype, (types.List, types.UnicodeType)):
msg = '{} Can only use .str accessor with string values. Given: {}'
raise TypingError(msg.format(_func_name, self.data.dtype))
def hpat_pandas_series_str_impl(self):
return pandas.core.strings.StringMethods(self)
return hpat_pandas_series_str_impl
示例3: hpat_pandas_series_len
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def hpat_pandas_series_len(self):
"""
Pandas Series operator :func:`len` implementation
.. only:: developer
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_len
"""
_func_name = 'Operator len().'
if not isinstance(self, SeriesType):
raise TypingError('{} The object must be a pandas.series. Given: {}'.format(_func_name, self))
def hpat_pandas_series_len_impl(self):
return len(self._data)
return hpat_pandas_series_len_impl
示例4: order
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def order(self):
"""return the order num of transaction/ for everyday change
Decorators:
lru_cache
Returns:
pd.series -- [description]
"""
return self.data.order
示例5: _create_plot_info
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def _create_plot_info(x_min, x_max, rect_width, y_max, plot_height):
"""Return the information on the plot specs in one dictionary.
Args:
x_min (pd.Series): see _calculate_x_bounds
x_max (pd.series): see _calculate_x_bounds
rect_width (pd.Series): The index are the parameter groups. The values
are the rectangle widths used in each group
y_max (float): maximum number of parameters that fall into one bin
plot_height (int): Plot height in pixels.
Returns:
plot_info (dict): of the form:
plot_height: plot_height
y_range: (0, y_max)
group_info:
group: {x_range: x_range, width: rect_width}
"""
group_plot_info = pd.concat([x_min, x_max, rect_width], axis=1)
group_plot_info["x_range"] = group_plot_info.apply(
lambda x: (x["x_min"], x["x_max"]), axis=1
)
group_plot_info.drop(columns=["x_min", "x_max"], inplace=True)
group_plot_info = group_plot_info.T.to_dict()
plot_info = {
"plot_height": plot_height,
"y_range": (0, y_max),
"group_info": group_plot_info,
}
return plot_info
示例6: fit
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def fit(self,init_data,data):
"""
Import data to SPOT object
Parameters
----------
init_data : list, numpy.array or pandas.Series
initial batch to calibrate the algorithm
data : numpy.array
data for the run (list, np.array or pd.series)
"""
if isinstance(data,list):
self.data = np.array(data)
elif isinstance(data,np.ndarray):
self.data = data
elif isinstance(data,pd.Series):
self.data = data.values
else:
print('This data format (%s) is not supported' % type(data))
return
if isinstance(init_data,list):
self.init_data = np.array(init_data)
elif isinstance(init_data,np.ndarray):
self.init_data = init_data
elif isinstance(init_data,pd.Series):
self.init_data = init_data.values
elif isinstance(init_data,int):
self.init_data = self.data[:init_data]
self.data = self.data[init_data:]
elif isinstance(init_data,float) & (init_data<1) & (init_data>0):
r = int(init_data*data.size)
self.init_data = self.data[:r]
self.data = self.data[r:]
else:
print('The initial data cannot be set')
return
示例7: transform
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def transform(self, x):
"""
Transform array|series x
"""
raise NotImplementedError('Not Implemented')
示例8: inverse
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def inverse(self, x):
"""
Inverse transform array|series x
"""
raise NotImplementedError('Not Implemented')
示例9: get_raw_price
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def get_raw_price(self, instrument_code):
"""
Returns a pd.series of prices
:param instrument_code: instrument to get carry data for
:type instrument_code: str
:returns: pd.DataSeries
>>> ans=RandomData()
>>> ans.generate_random_data("wibble", 10, 5, 5, 0.0)
>>> ans.get_raw_price("wibble")
1980-01-01 0.0
1980-01-02 1.0
1980-01-03 2.0
1980-01-04 3.0
1980-01-07 4.0
1980-01-08 5.0
1980-01-09 4.0
1980-01-10 3.0
1980-01-11 2.0
1980-01-14 1.0
Freq: B, dtype: float64
"""
if instrument_code in self.get_instrument_list():
## must have been cached
return self._price_cache_random_data[instrument_code]
error_msg = "No price found for %s you need to run .generate_random_data(instrument_code=%s....)" % (
instrument_code, instrument_code)
self.log.critical(error_msg)
示例10: generate_noise
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def generate_noise(Nlength, stdev):
"""
Generates a series of gaussian noise as a list Nlength
:param Nlength: total number of returns to generate
:type Nlength: int
:param stdev: Standard deviation of noise
:type stdev: float
:returns: returns a vector of numbers as a list, length Nlength
"""
return [gauss(0.0, stdev) for Unused in range(Nlength)]
示例11: hpat_pandas_series_shape
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def hpat_pandas_series_shape(self):
"""
Intel Scalable Dataframe Compiler User Guide
********************************************
Pandas API: pandas.Series.shape
Examples
--------
.. literalinclude:: ../../../examples/series/series_shape.py
:language: python
:lines: 27-
:caption: Return a tuple of the shape of the underlying data.
:name: ex_series_shape
.. command-output:: python ./series/series_shape.py
:cwd: ../../../examples
Intel Scalable Dataframe Compiler Developer Guide
*************************************************
Pandas Series attribute :attr:`pandas.Series.shape` implementation
.. only:: developer
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_shape1
"""
_func_name = 'Attribute shape.'
ty_checker = TypeChecker(_func_name)
ty_checker.check(self, SeriesType)
def hpat_pandas_series_shape_impl(self):
return self._data.shape
return hpat_pandas_series_shape_impl
示例12: hpat_pandas_series_size
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def hpat_pandas_series_size(self):
"""
Intel Scalable Dataframe Compiler User Guide
********************************************
Pandas API: pandas.Series.size
Examples
--------
.. literalinclude:: ../../../examples/series/series_size.py
:language: python
:lines: 27-
:caption: Return the number of elements in the underlying data.
:name: ex_series_size
.. command-output:: python ./series/series_size.py
:cwd: ../../../examples
Intel Scalable Dataframe Compiler Developer Guide
*************************************************
Pandas Series attribute :attr:`pandas.Series.size` implementation
.. only:: developer
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_size
"""
_func_name = 'Attribute size.'
ty_checker = TypeChecker(_func_name)
ty_checker.check(self, SeriesType)
def hpat_pandas_series_size_impl(self):
return len(self._data)
return hpat_pandas_series_size_impl
示例13: hpat_pandas_series_ndim
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def hpat_pandas_series_ndim(self):
"""
Intel Scalable Dataframe Compiler User Guide
********************************************
Pandas API: pandas.Series.ndim
Examples
--------
.. literalinclude:: ../../../examples/series/series_ndim.py
:language: python
:lines: 27-
:caption: Number of dimensions of the underlying data, by definition 1.
:name: ex_series_ndim
.. command-output:: python ./series/series_ndim.py
:cwd: ../../../examples
Intel Scalable Dataframe Compiler Developer Guide
*************************************************
Pandas Series attribute :attr:`pandas.Series.ndim` implementation
.. only:: developer
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_getattr_ndim
"""
_func_name = 'Attribute ndim.'
ty_checker = TypeChecker(_func_name)
ty_checker.check(self, SeriesType)
def hpat_pandas_series_ndim_impl(self):
return 1
return hpat_pandas_series_ndim_impl
示例14: hpat_pandas_series_T
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def hpat_pandas_series_T(self):
"""
Intel Scalable Dataframe Compiler User Guide
********************************************
Pandas API: pandas.Series.T
Examples
--------
.. literalinclude:: ../../../examples/series/series_T.py
:language: python
:lines: 27-
:caption: Return the transpose, which is by definition self.
:name: ex_series_T
.. command-output:: python ./series/series_T.py
:cwd: ../../../examples
Intel Scalable Dataframe Compiler Developer Guide
*************************************************
Pandas Series attribute :attr:`pandas.Series.T` implementation
.. only:: developer
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_getattr_T
"""
_func_name = 'Attribute T.'
ty_checker = TypeChecker(_func_name)
ty_checker.check(self, SeriesType)
def hpat_pandas_series_T_impl(self):
return self._data
return hpat_pandas_series_T_impl
示例15: generate_one_row
# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import series [as 别名]
def generate_one_row(row, flag=True):
"""
Input: one row data of pandas.series
Output: the answer string
"""
if flag:
ans = '\t'.join([row.id, row.homepage, row.gender, row.position, row.pic, row.email, row.location])
else:
ans = '\t'.join([row.expert_id, row.homepage_url, row.gender, row.position, row.person_photo, row.email, row.location])
return ans + '\n'