Why does dataframe type change after exporting in Colab

I did export the following dataframe in Google Colab. Whichever method I used, when I import it later, my dataframe appears as pandas.core.series.Series, not as an array.

enter image description here

from google.colab import drive

drive.mount('/content/drive')
path = '/content/drive/My Drive/output.csv'

with open(path, 'w', encoding = 'utf-8-sig') as f:
  df_protein_final.to_csv(f)

After importing the dataframe looks like below

enter image description here

pandas.core.series.Series

Note: The first image and second image can be different order in terms of numbers (It can be look as a different dataset). Please don't get hung up on this. Don't worry. Those images are just an example.

Why does column, which is originally an array before exporting, converts to series after exporting?

The code below gives the same result. Can't export original structure.

from google.colab import files
df.to_csv('filename.csv') 
files.download('filename.csv')

Edit: I am looking for a solution is there any way to keep original structure (e.g. array) while exporting.



Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept