#๐ the squeeze parameter was deleted from pandas, what should I do ?
18 messages ยท Page 1 of 1 (latest)
@scenic mason
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Can you elaborate?
with the pandas library there was the squeeze parameter allowing you to create a Series, the problem is that this parameter no longer exists and I can't find how to replace it
On what function?
read_csv
and read_table, read_excel ...
I can't find info about that function ever having had a squeeze parameter, but anyway - if you want to take the only column of a dataframe, just do that via indexing, e.g. .iloc[:, 0].
yes but I would like to understand why pandas were removed when it allowed you to create Series easily
Well, when I switch through the old versions of the read_csv docs, I don't see a squeeze parameter anywhere on any version. So I don't know what you mean.
ah, I found it
looks like they just thought it's useless, which makes sense:
Not only useless/redundant, but also confusing. If the csv file contains multiple columns, the parameter would do nothing, and still return the full dataframe.
The implementation was py if self.squeeze and len(df.columns) == 1: return df[df.columns[0]].copy() return dfhttps://github.com/pandas-dev/pandas/blob/15302106ef41e562d2f80c6d1ecffdd4aea7158a/pandas/io/parsers/readers.py#L1063C1-L1065C18
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ the squeeze parameter was deleted from pandas, what should I do ?