1
df.columns = range(len(df.columns)) inplace = True

File "<ipython-input-32-660063f3ffb1>", line 1

df.columns = range(len(df.columns)inplace = True)
                                        ^

SyntaxError: invalid syntax

If I remove "inplace = True" I get the correct solution but its not permanent. Perhaps there is a better way of doing this

Original data frame:

    sepal_length    sepal_width petal_length    petal_width  species
0     5.1                 3.5           1.4         0.2        setosa
1     4.9                 3.0           1.4         0.2        setosa
2     4.7                 3.2           1.3         0.2        setosa
3     4.6                 3.1           1.5         0.2        setosa
4     5.0                 3.6           1.4         0.2        setosa

Desired dataframe:

    0   1   2   3   4
0   5.1 3.5 1.4 0.2 setosa
1   4.9 3.0 1.4 0.2 setosa
2   4.7 3.2 1.3 0.2 setosa
3   4.6 3.1 1.5 0.2 setosa
4   5.0 3.6 1.4 0.2 setosa
vimuth
  • 5,064
  • 33
  • 79
  • 116

0 Answers0