When I read in a .txt file python gives automatic names that are not very useful (i.e. 0, 0.1, 0.2, 0.3...). How do I rename all my columns without having to explicitly type it all?
当我读入.txt文件时,python会给出不太有用的自动名称(即0,0.1,0.2,0.3 ......)。如何重命名我的所有列而不必显式输入所有列?
For example, how do I quickly rename the variables V1 to V200?
例如,如何快速将变量V1重命名为V200?
1 个解决方案
#1
df.columns = ["feature_"+str(x) for x in range(len(df.columns))]
#1
df.columns = ["feature_"+str(x) for x in range(len(df.columns))]