0

Dataframe looks like below

enter image description here

I have dataframe like above. which I want to a~t reshape (a~t, 1)

I want to reshape dataframe like below



날짜      역번호 역명  구분    a

2018-01-01  150 서울역 승차  379

2018-01-01  150 서울역 승차  287

2018-01-01  150 서울역 승차  371

2018-01-01  150 서울역 승차  876

2018-01-01  150 서울역 승차  965

....
2008-01-01  152 종각  승차  2920

2008-01-01  152 종각  승차  2290

2008-01-01  152 종각  승차  802

2008-01-01  152 종각  승차  1559

like df = df.reshape(len(data2)*a~t, 1)

i tried pd.melt but It does not work well.

df2 = pd.melt(df, id_vars=["날짜", "역번호", "역명", "구분"], value_name="t")

is remove b~t i want insert b~t behind a

dataset is https://drive.google.com/file/d/1Upb5PgymkPB5TXuta_sg6SijwzUuEkfl/view?usp=sharing

GoBackess
  • 404
  • 3
  • 17
  • i edit this quesition and this is different question and i didn't get answer so, please unmarked as duplicate – GoBackess Apr 05 '19 at 09:39
  • I think `melt` here working nice, maybe `sort_values` is necessary for corect sorting or use alternative solution with `set_index` + `stack` from dupe. – jezrael Apr 05 '19 at 11:45
  • if i use melt the column of 'b~ t' is deleted... i want add 'b~t' column is go to under 'a' column but the melt is delete column 'b~t' it's not working on my dataframe... am i wrong to apply melt?? – GoBackess Apr 05 '19 at 13:25

0 Answers0