【Python】reset_index函数
生活随笔
收集整理的這篇文章主要介紹了
【Python】reset_index函数
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
DataFrame的reset_index()函數(shù)用法:
import pandas as pd import numpy as np df = pd.DataFrame(data={'A':[1,1,2,2,2],'B':[2,3,4,6,5],'C':[3,8,5,12,6] }) dfA B C 0 1 2 3 1 1 3 8 2 2 4 5 3 2 6 12 4 2 5 6 ############################# df = df.ix[[0,2,4]] dfA B C 0 1 2 3 2 2 4 5 4 2 5 6 ############################# df.reset_index() #將會將原來的索引index作為新的一列index A B C 0 0 1 2 3 1 2 2 4 5 2 4 2 5 6 ############################# #使用drop參數(shù)設置去掉原索引 df.reset_index(drop=True)A B C 0 1 2 3 1 2 4 5 2 2 5 6我們下次再見,如果還有下次的話!!!
歡迎關注微信公眾號:516數(shù)據(jù)工作室
總結
以上是生活随笔為你收集整理的【Python】reset_index函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unbuntu ./btest : c
- 下一篇: websocket python爬虫_p