Transform columns into rows in a dataframe

1

I have a dataframe with columns:

LUC
Contrato
Fantasia
Ano
Mes
01
02
03
05
...
30
Tatividade

I need to turn these columns with the days of the month into rows. In each column has the value sold that day by the store. It would have to look like this:

LUC
Contrato
Fantasia
Ano 
mes
dia
valor

I've tried the code:

vendas = pd.melt(vendas.reset_index(), id_vars=['LUC', 'Contrato','Fantasia','ano','mes','Tatividade'], 
var_name='dia', value_name='valor')

The columns were created, but the values were incorrect. In the day column was the index value and in the column value was a numerical sequence.

    
asked by anonymous 06.12.2017 / 02:03

1 answer

1

Tried to transpose the dataframe?

It does the inversion between rows and columns.

pd = pd.T
    
06.12.2017 / 12:17