User1011
User1011

Reputation: 135

I want to convert multiple columns into rows but along with it's corresponding data

Currently my dataframe looks like this,

enter image description here

And I want something like this,

  Filename    Data_Extracted
  file1        data of file1
  file2        data of file2

Currently File1 & File2 are actually the columns of the dataframe and data of file1 & file 2 are the records

is there any way to do that?

Upvotes: 0

Views: 77

Answers (1)

Derek O
Derek O

Reputation: 19565

If your dictionary has the structure {filename1: data1, filename2: data2, ...}, then you can do something like this:

df = pd.DataFrame(data=filename_dict.items(), columns=['Filename', 'Data_Extracted'])

Upvotes: 1

Related Questions