mercredi 13 juillet 2016

Transforming a column in index Python pandas


I have the following DataFrame:

   index    PUBLICO     CLASSIFICACAO_PUBLICO
0   19      143643          1
1   34      111879          2
2   31       50382          3
3   9        49204          4
4   32       37541          5
5   4        36095          6

I need convert the index name column to index column.

For example:

index   PUBLICO     CLASSIFICACAO_PUBLICO
19      143643          1
34      111879          2
31       50382          3
9        49204          4
32       37541          5
4        36095          6

I try use df.set_index('index'), but it didn't work.

The column with the name index previously was the index column the DataFrame, but I used the reset_index, because I needed, now I need to do the reverse.

I apologize for any error. The English isn't my language.


Aucun commentaire:

Enregistrer un commentaire