DataFrame 重命名列名rename
import pandas as pd # 创建示例 DataFrame data = { 'OldName1': [1, 2, 3], 'OldName2': [4, 5, 6] } df = pd.DataFrame(data) # 重命名列名 new_column_names = { 'OldName1': 'NewName1', 'OldName2': 'NewName2' } df.rename(columns=new_column_names, inplace=True) print("DataFrame with renamed column names:") print(df)
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/17614344.html