运行 ❯
获取您自己的
Python
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
import pandas as pd data = { "age": [50, 40, 30], "qualified": [True, False, False] } idx = ["Sally", "Mary", "John"] df = pd.DataFrame(data, index=idx) newdf = df.rename({"Sally": "Pete", "Mary": "Patrick", "John": "Paula"}) print(newdf)
age qualified Pete 50 True Patrick 40 False Paula 30 False