
Python始めました。pandas 1からindex を取り直す
データフレームのインデックスを再設定する
┗ reset_indexメソッドを使う
1 から始まるインデックスを振り直す
┗ NumPyのarangeメソッドを使う
import pandas as pd
df=pd.read_excel('./~.xlsx')
df.reset_index(drop=True, inplace=True)
import numpy as np
df.index = np.arange(1, len(df)+1)
print(df)
少しつまづいたのでメモしました。
いいなと思ったら応援しよう!
