Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary length checks in df.squeeze #7315

Open
sfc-gh-dpetersohn opened this issue Jun 14, 2024 · 0 comments
Open

Avoid unnecessary length checks in df.squeeze #7315

sfc-gh-dpetersohn opened this issue Jun 14, 2024 · 0 comments

Comments

@sfc-gh-dpetersohn
Copy link
Contributor

It is possible that when axis=1 in squeeze we still check len(self.index), which is never necessary when axis=1. Link to code here:

if axis is None and (len(self.columns) == 1 or len(self.index) == 1):
return Series(query_compiler=self._query_compiler).squeeze()
if axis == 1 and len(self.columns) == 1:
self._query_compiler._shape_hint = "column"
return Series(query_compiler=self._query_compiler)
if axis == 0 and len(self.index) == 1:
qc = self.T._query_compiler
qc._shape_hint = "column"
return Series(query_compiler=qc)
else:
return self.copy()

This is an easy fix, also see snowflakedb/snowpark-python#1767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant