zoukankan      html  css  js  c++  java
  • pandas --index ,reindex, set_index, reset_index , reindex_like函数 之 reset_index

    
    reset_index(
        level: Union[Hashable, Sequence[Hashable], NoneType] = None,
        drop: bool = False,
        inplace: bool = False,
        col_level: Hashable = 0,
        col_fill: Union[Hashable, NoneType] = '',
    ) -> Union[ForwardRef('DataFrame'), NoneType]
    Docstring:
    Reset the index, or a level of it.
    
    Reset the index of the DataFrame, and use the default one instead.
    If the DataFrame has a MultiIndex, this method can remove one or more
    levels.
    
    Parameters
    ----------
    level : int, str, tuple, or list, default None
        Only remove the given levels from the index. Removes all levels by
        default.
    drop : bool, default False
        Do not try to insert index into dataframe columns. This resets
        the index to the default integer index.
    inplace : bool, default False
        Modify the DataFrame in place (do not create a new object).
    col_level : int or str, default 0
        If the columns have multiple levels, determines which level the
        labels are inserted into. By default it is inserted into the first
        level.
    col_fill : object, default ''
        If the columns have multiple levels, determines how the other
        levels are named. If None then the index name is repeated.
    
    Returns
    -------
    DataFrame or None
        DataFrame with the new index or None if ``inplace=True``.
    

    reset_index()

    • 函数原型:DataFrame.reset_index(level=None, drop=False, inplace=False, col_level=0, col_fill='')
    • 参数解释:
      level:int、str、tuple或list,默认无,仅从索引中删除给定级别。默认情况下移除所有级别。控制了具体要还原的那个等级的索引
      drop:drop为False则索引列会被还原为普通列,否则会丢失
      inplace:默认为false,适当修改DataFrame(不要创建新对象)
      col_level:int或str,默认值为0,如果列有多个级别,则确定将标签插入到哪个级别。默认情况下,它将插入到第一级。
      col_fill:对象,默认‘’,如果列有多个级别,则确定其他级别的命名方式。如果没有,则重复索引名
    • 注:reset_index还原分为两种类型,第一种是对原DataFrame进行reset,第二种是对使用过set_index()函数的DataFrame进行reset



  • 相关阅读:
    快速免费用宝塔面板加开源小程序商城源码搭建自己的商城程序
    小程序商城,到底是购买源码好还是直接使用SaaS平台好?
    51单片机串口通信的注记
    关于vi 分屏的一些指令
    偶遇bash 的while read line 的问题
    centos 6 设置无密码登录ssh 不成功问题
    关于js框架 dwz 与 yii的的分页 以及筛选的结合
    完美解决百度地图MarkerClusterer 移动地图时,Marker 的Label 丢失的问题
    微信小程序购物商城系统开发系列-目录结构
    微信小程序支付步骤
  • 原文地址:https://www.cnblogs.com/vincent-sh/p/12861608.html
Copyright © 2011-2022 走看看