當前位置: 首頁>>代碼示例>>Python>>正文


Python pandas.series方法代碼示例

本文整理匯總了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) 
開發者ID:has2k1,項目名稱:plotnine,代碼行數:18,代碼來源:scale.py

示例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 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:23,代碼來源:hpat_pandas_series_functions.py

示例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 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:19,代碼來源:hpat_pandas_series_functions.py

示例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 
開發者ID:QUANTAXIS,項目名稱:QUANTAXIS,代碼行數:13,代碼來源:QADataStruct.py

示例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 
開發者ID:OpenSourceEconomics,項目名稱:estimagic,代碼行數:32,代碼來源:comparison_plot_data_preparation.py

示例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 
開發者ID:Amossys-team,項目名稱:SPOT,代碼行數:41,代碼來源:spot.py

示例7: transform

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import series [as 別名]
def transform(self, x):
        """
        Transform array|series x
        """
        raise NotImplementedError('Not Implemented') 
開發者ID:has2k1,項目名稱:plotnine,代碼行數:7,代碼來源:scale.py

示例8: inverse

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import series [as 別名]
def inverse(self, x):
        """
        Inverse transform array|series x
        """
        raise NotImplementedError('Not Implemented') 
開發者ID:has2k1,項目名稱:plotnine,代碼行數:7,代碼來源:scale.py

示例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) 
開發者ID:robcarver17,項目名稱:pysystemtrade,代碼行數:36,代碼來源:randomdata.py

示例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)] 
開發者ID:robcarver17,項目名稱:pysystemtrade,代碼行數:17,代碼來源:randomdata.py

示例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 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:37,代碼來源:hpat_pandas_series_functions.py

示例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 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:37,代碼來源:hpat_pandas_series_functions.py

示例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 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:37,代碼來源:hpat_pandas_series_functions.py

示例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 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:37,代碼來源:hpat_pandas_series_functions.py

示例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' 
開發者ID:geekinglcq,項目名稱:aca,代碼行數:12,代碼來源:first.py


注:本文中的pandas.series方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。