I have a dataset which i need to unpivot into muliple rows.
Eg:
id cor_id1 mail11 mail12 mail13 cor_id2 mail21 mail22 mail23 cor_id3 mail31 mail32 mail33
1 1 a@123 b@234 c@123 2 a@def b@fgh c@asd 3 s@wer b@ert e@rty
2 4 e@234 e@234 e@qwe 9 e@dfe f@jfg r@ert 10 e@wer g@wer e@ert
I need to unpivot them as
id cor_id mail
1 1 a@123
1 1 b@234
1 1 c@123
1 2 a@def
1 2 b@fgh
1 2 c@asd
1 3 s@wer
1 3 b@ert
1 3 e@rty
2 4 e@234
2 4 e@234
2 4 e@qwe
2 9 e@dfe
2 9 r@ert
2 10 e@wer
2 10 g@wer
2 10 e@ert
I have tried df.melt but that that is giving for only 1 column.
What if the data has multiple columns to be converted to rows.
id cor_id1 ad1 mail11 mail12 mail13 cor_id2 ad2 mail21 mail22 mail23 cor_id3 ad3 mail31 mail32 mail33
1 1 23 a@123 b@234 c@123 2 24 a@def b@fgh c@asd 3 25 s@wer b@ert e@rty
2 4 33 e@234 e@234 e@qwe 9 34 e@dfe f@jfg r@ert 10 35 e@wer g@wer e@ert
and i want
id cor_id ad mail
1 1 23 a@123
1 1 23 b@234
1 1 23 c@123
1 2 24 a@def
1 2 24 b@fgh
1 2 24 c@asd
1 3 25 s@wer
1 3 25 b@ert
1 3 25 e@rty
2 4 33 e@234
2 4 33 e@234
2 4 33 e@qwe
2 9 34 e@dfe
2 9 34 f@jfg
2 9 34 r@ert
2 10 35 e@wer
2 10 35 g@wer
2 10 35 e@ert