当前位置: 首页>>代码示例>>Python>>正文


Python pandas.set_option方法代码示例

本文整理汇总了Python中pandas.set_option方法的典型用法代码示例。如果您正苦于以下问题:Python pandas.set_option方法的具体用法?Python pandas.set_option怎么用?Python pandas.set_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas的用法示例。


在下文中一共展示了pandas.set_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print_para

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def print_para(model):
    """
    Prints parameters of a model
    :param opt:
    :return:
    """
    st = {}
    total_params = 0
    total_params_training = 0
    for p_name, p in model.named_parameters():
        # if not ('bias' in p_name.split('.')[-1] or 'bn' in p_name.split('.')[-1]):
        st[p_name] = ([str(x) for x in p.size()], np.prod(p.size()), p.requires_grad)
        total_params += np.prod(p.size())
        if p.requires_grad:
            total_params_training += np.prod(p.size())
    pd.set_option('display.max_columns', None)
    shapes_df = pd.DataFrame([(p_name, '[{}]'.format(','.join(size)), prod, p_req_grad)
                              for p_name, (size, prod, p_req_grad) in sorted(st.items(), key=lambda x: -x[1][1])],
                             columns=['name', 'shape', 'size', 'requires_grad']).set_index('name')

    print('\n {:.1f}M total parameters. {:.1f}M training \n ----- \n {} \n ----'.format(total_params / 1000000.0,
                                                                                        total_params_training / 1000000.0,
                                                                                        shapes_df.to_string()),
          flush=True)
    return shapes_df 
开发者ID:yuweijiang,项目名称:HGL-pytorch,代码行数:27,代码来源:pytorch_misc.py

示例2: daily_stats

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def daily_stats(data: (pd.Series, pd.DataFrame), **kwargs) -> pd.DataFrame:
    """
    Daily stats for given data

    Examples:
        >>> pd.set_option('precision', 2)
        >>> (
        ...     pd.concat([
        ...         pd.read_pickle('xbbg/tests/data/sample_rms_ib0.pkl'),
        ...         pd.read_pickle('xbbg/tests/data/sample_rms_ib1.pkl'),
        ...     ], sort=False)
        ...     .pipe(get_series, col='close')
        ...     .pipe(daily_stats)
        ... )['RMS FP Equity'].iloc[:, :5]
                                   count    mean   std    min    10%
        2020-01-16 00:00:00+00:00  434.0  711.16  1.11  708.6  709.6
        2020-01-17 00:00:00+00:00  437.0  721.53  1.66  717.0  719.0
    """
    if data.empty: return pd.DataFrame()
    if 'percentiles' not in kwargs: kwargs['percentiles'] = [.1, .25, .5, .75, .9]
    return data.groupby(data.index.floor('d')).describe(**kwargs) 
开发者ID:alpha-xone,项目名称:xbbg,代码行数:23,代码来源:pipeline.py

示例3: execute

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def execute(cls, ctx, op: "DataFrameDropNA"):
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)

            in_data = ctx[op.inputs[0].key]
            if op.drop_directly:
                if in_data.ndim == 2:
                    result = in_data.dropna(axis=op.axis, how=op.how, thresh=op.thresh,
                                            subset=op.subset)
                else:
                    result = in_data.dropna(axis=op.axis, how=op.how)
                ctx[op.outputs[0].key] = result
                return

            in_counts = ctx[op.inputs[1].key]
            if op.how == 'all':
                in_counts = in_counts[in_counts > 0]
            else:
                thresh = op.subset_size if op.thresh is None else op.thresh
                in_counts = in_counts[in_counts >= thresh]

            ctx[op.outputs[0].key] = in_data.reindex(in_counts.index)
        finally:
            pd.reset_option('mode.use_inf_as_na') 
开发者ID:mars-project,项目名称:mars,代码行数:26,代码来源:dropna.py

示例4: execute

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def execute(cls, ctx, op):
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)
            if op.stage == OperandStage.map:
                cls._execute_map(ctx, op)
            elif op.stage == OperandStage.combine:
                cls._execute_combine(ctx, op)
            else:
                input_data = ctx[op.inputs[0].key]
                value = getattr(op, 'value', None)
                if isinstance(op.value, (Base, Entity)):
                    value = ctx[op.value.key]
                ctx[op.outputs[0].key] = input_data.fillna(
                    value=value, method=op.method, axis=op.axis, limit=op.limit, downcast=op.downcast)
        finally:
            pd.reset_option('mode.use_inf_as_na') 
开发者ID:mars-project,项目名称:mars,代码行数:18,代码来源:fillna.py

示例5: execute

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def execute(cls, ctx, op: "DataFrameAggregate"):
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)
            if op.stage == OperandStage.map:
                cls._execute_map(ctx, op)
            elif op.stage == OperandStage.combine:
                cls._execute_combine(ctx, op)
            elif op.stage == OperandStage.agg:
                cls._execute_agg(ctx, op)
            elif op.raw_func == 'size':
                xp = cp if op.gpu else np
                ctx[op.outputs[0].key] = xp.array(ctx[op.inputs[0].key].agg(op.raw_func, axis=op.axis)) \
                    .reshape(op.outputs[0].shape)
            else:
                ctx[op.outputs[0].key] = ctx[op.inputs[0].key].agg(op.raw_func, axis=op.axis)
        finally:
            pd.reset_option('mode.use_inf_as_na') 
开发者ID:mars-project,项目名称:mars,代码行数:19,代码来源:aggregation.py

示例6: job_table

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def job_table(self, project=None, recursive=True, columns=None, all_columns=False, sort_by="id", max_colwidth=200,
                  job_name_contains=''):
        if project is None:
            project = self._project
        if columns is None:
            columns = ["job", "project", "chemicalformula"]
        if all_columns:
            columns = self._columns
        if len(self._job_table) != 0:
            if recursive:
                df = self._job_table[self._job_table.project.str.contains(project)]
            else:
                df = self._job_table[self._job_table.project == project]
        else:
            df = self._job_table
        pandas.set_option("display.max_colwidth", max_colwidth)
        if len(df) == 0:
            return df
        if job_name_contains != '':
            df = df[df.job.str.contains(job_name_contains)]
        if sort_by in columns:
            return df[columns].sort_values(by=sort_by)
        return df[columns] 
开发者ID:pyiron,项目名称:pyiron,代码行数:25,代码来源:filetable.py

示例7: write_to_html

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def write_to_html(self):
        pandas.set_option('display.max_colwidth', -1)
        header = '{!s}'.format(self.df.index.tolist()[0])
        df = self.df.reset_index(level=['Clf.', 'Set_Type', 'Eval.'])
        if '#Rep.' in df:
            df.drop('#Rep.', 1, inplace=True)

        df.drop('Eval.', 1, inplace=True)
        df.drop('Set_Size', 1, inplace=True)
        df.drop('Set_Type', 1, inplace=True)
        df.drop('f1', 1, inplace=True)
        df.drop('precision', 1, inplace=True)
        df.columns = ['Clf', '\\ac{DGA} Type', '\\ac{ACC}', '\\ac{TPR}', '\\ac{TNR}', '\\ac{FNR}', '\\ac{FPR}']
        fname = settings.ANALYSIS_FOLDER + '/eval_full.html'
        with open(fname, 'w') as f:
            f.write(df.to_html())
        pandas.reset_option('display.max_colwidth') 
开发者ID:fanci-dga-detection,项目名称:fanci,代码行数:19,代码来源:stats_metrics.py

示例8: rsi

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def rsi(df, n=6):
    """
    相对强弱指标(Relative Strength Index,简称RSI
    LC= REF(CLOSE,1)
    RSI=SMA(MAX(CLOSE-LC,0),N,1)/SMA(ABS(CLOSE-LC),N1,1)×100
    SMA(C,N,M)=M/N×今日收盘价+(N-M)/N×昨日SMA(N)
    """
    # pd.set_option('display.max_rows', 1000)
    _rsi = pd.DataFrame()
    _rsi['date'] = df['date']
    px = df.close - df.close.shift(1)
    px[px < 0] = 0
    _rsi['rsi'] = sma(px, n) / sma((df['close'] - df['close'].shift(1)).abs(), n) * 100
    # def tmax(x):
    #     if x < 0:
    #         x = 0
    #     return x
    # _rsi['rsi'] = sma((df['close'] - df['close'].shift(1)).apply(tmax), n) / sma((df['close'] - df['close'].shift(1)).abs(), n) * 100
    return _rsi 
开发者ID:waditu,项目名称:tushare,代码行数:21,代码来源:trendline.py

示例9: bbiboll

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def bbiboll(df, n=10, k=3):
    """
    BBI多空布林线	bbiboll(10,3)
    BBI={MA(3)+ MA(6)+ MA(12)+ MA(24)}/4
    标准差MD=根号[∑(BBI-MA(BBI,N))^2/N]
    UPR= BBI+k×MD
    DWN= BBI-k×MD
    """
    # pd.set_option('display.max_rows', 1000)
    _bbiboll = pd.DataFrame()
    _bbiboll['date'] = df.date
    _bbiboll['bbi'] = (_ma(df.close, 3) + _ma(df.close, 6) + _ma(df.close, 12) + _ma(df.close, 24)) / 4
    _bbiboll['md'] = _md(_bbiboll.bbi, n)
    _bbiboll['upr'] = _bbiboll.bbi + k * _bbiboll.md
    _bbiboll['dwn'] = _bbiboll.bbi - k * _bbiboll.md
    return _bbiboll 
开发者ID:waditu,项目名称:tushare,代码行数:18,代码来源:trendline.py

示例10: df_to_string

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def df_to_string(df):
    """
    Create a formatted str representation of the DataFrame.

    Parameters
    ----------
    df: DataFrame

    Returns
    -------
    str

    """
    pd.set_option('display.expand_frame_repr', False)
    pd.set_option('precision', 8)
    pd.set_option('display.width', 1000)
    pd.set_option('display.max_colwidth', 1000)

    return df.to_string() 
开发者ID:enigmampc,项目名称:catalyst,代码行数:21,代码来源:stats_utils.py

示例11: list_groups

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def list_groups(dim=3):
    """
    Function for quick print of groups and symbols

    Args:
        group: the group symbol or international number
        dim: the periodic dimension of the group
    """
    
    import pandas as pd

    keys = {3: 'space_group',
            2: 'layer_group',
            1: 'rod_group',
            0: 'point_group',
           }
    data = symbols[keys[dim]]
    df = pd.DataFrame(index=range(1, len(data)+1), 
                      data=data, 
                      columns=[keys[dim]])
    pd.set_option('display.max_rows', len(df))
    #df.set_index('Number')
    print(df) 
开发者ID:qzhu2017,项目名称:PyXtal,代码行数:25,代码来源:symmetry.py

示例12: _set_display_options

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def _set_display_options(self):
        """
        Set pandas display options. Display all rows and columns by default.
        """
        display_options = {'display.max_rows': None,
                           'display.max_columns': None,
                           'display.width': None,
                           'display.max_colwidth': None}

        for k in display_options:
            try:
                pd.set_option(k, display_options[k])
            except ValueError:
                msg = """Newer version of Pandas required to set the '{}'
                         option.""".format(k)
                warnings.warn(msg) 
开发者ID:tompollard,项目名称:tableone,代码行数:18,代码来源:tableone.py

示例13: configure_tests

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def configure_tests():
    pd.set_option('chained_assignment', 'raise')


# For running doctests: make np and pd names available 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:conftest.py

示例14: test_format_sparse_config

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def test_format_sparse_config(idx):
    warn_filters = warnings.filters
    warnings.filterwarnings('ignore', category=FutureWarning,
                            module=".*format")
    # GH1538
    pd.set_option('display.multi_sparse', False)

    result = idx.format()
    assert result[1] == 'foo  two'

    tm.reset_display_options()

    warnings.filters = warn_filters 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_format.py

示例15: test_use_bottleneck

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import set_option [as 别名]
def test_use_bottleneck():

    if nanops._BOTTLENECK_INSTALLED:

        pd.set_option('use_bottleneck', True)
        assert pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', False)
        assert not pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', use_bn) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_nanops.py


注:本文中的pandas.set_option方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。