I have a dataframe like this,
data = {'first_column': ['first_sentence', 'second_sentence'], 'second_column': ['A', 'B'], 'third_column' : ['C', 'D'] }
The original structure like this
first_column second_column third_column
first_sentence A C
second_sentence B D
I want to convert it into following format
first_column column
first_sentence A
first_sentence C
second_sentence B
second_sentence D
I tried df.stack()
but it gives
0 first_column first_sentence
second_column A
third_column C
1 first_column second_sentence
second_column B
third_column D
I have around 27 columns in original dataframe and i want to produce 1 column, how can i do this
thank you in advance.
