-2

I tried to give the name to columns in python using pandas, the problem is my data has 52 columns and I want to set a name only for the first 3 columns, what should I do?

Here's what my data looks like after df = pd.read_csv

cocoph
  • 23
  • 5
  • 1
    Please [do not post images](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) of your data. You can include [code that creates a dataframe or the output of `print(df)`](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) (or of a few rows and columns that allow to reproduce the example) – Cimbali Jul 06 '21 at 08:55

1 Answers1

1

You can use the rename method

df.rename(columns={0: 'x', 1: 'y', 2: 'z'}, inplace=True)