Skip to content
Advertisement

When I read a csv with squeeze is set to True in Pandas it makes dataframe not series

Was able to import a CSV while trying to perform squeeze but it looks like a data frame instead of a series?

This is what I tried

JavaScript

this is what I expected at least I remember learning the output was not a data frame but more like a series?

I was expecting it would come in like a series and less like data frame and look something like this

JavaScript
JavaScript

this is the errors

But instead, I received an error

JavaScript

error received

JavaScript

I also was tried this which worded but also didn’t look as expected

JavaScript

Note: non-picture data frame below

link to actual dataframe csv csv on github

JavaScript

I can import it normally into a data frame and I get the

JavaScript

After fixing import using siamak safari comments

JavaScript
JavaScript

As pointed out by Gregor what I am trying will not work with multiple columns but if i make new csv with only 2 columns one for index and another it works.

enter image description here

JavaScript

Advertisement

Answer

The parameter squeeze is DEPRECATED since pandas version 1.4.0.

Append .squeeze("columns") to a dataframe, and you will get a series.

See document: https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement