例子:
df1 = pd.DataFrame(np.arange(9).reshape(3,3),index=["BJ","SH","GZ"],columns=["a","b","c"])
>>>
a b c BJ 0 1 2 SH 3 4 5 GZ 6 7 8
方法一:
df1.index = pd.Series(["bj","sh","gz"])
方法二:
df1.index = df1.index.map(str.upper)
方法三:
df1.rename(columns=str.upper)
df1.rename(index={"BJ":"herb"},columns=str.upper)