-
Notifications
You must be signed in to change notification settings - Fork 52
feat: add allow_large_results option #1428
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
Changes from 18 commits
1f39765
f0b632e
9c1e9db
50abb66
6ba3d12
63a422c
d204c56
8585ab8
6bbeeea
c9e67b0
1277613
bb6c9bf
8ced1b6
475958c
584d27d
e7977fd
df078c3
3c75a46
1bc2eb1
b7d6592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -490,17 +490,28 @@ def __getitem__(self, key: int) -> typing.Any: | |||||
else: | ||||||
raise NotImplementedError(f"Index key not supported {key}") | ||||||
|
||||||
def to_pandas(self) -> pandas.Index: | ||||||
def to_pandas(self, allow_large_results: Optional[bool] = None) -> pandas.Index: | ||||||
"""Gets the Index as a pandas Index. | ||||||
|
||||||
Args: | ||||||
allow_large_results (bool, default None): | ||||||
If not None, overrides the global setting to allow or disallow large query results | ||||||
over the default size limit of 10 GB. | ||||||
|
||||||
Returns: | ||||||
pandas.Index: | ||||||
A pandas Index with all of the labels from this Index. | ||||||
""" | ||||||
return self._block.index.to_pandas(ordered=True) | ||||||
df, query_job = self._block.index.to_pandas( | ||||||
ordered=True, allow_large_results=allow_large_results | ||||||
) | ||||||
self._query_job = query_job | ||||||
return df | ||||||
|
||||||
def to_numpy(self, dtype=None, **kwargs) -> np.ndarray: | ||||||
return self.to_pandas().to_numpy(dtype, **kwargs) | ||||||
def to_numpy(self, dtype=None, allow_large_results=None, **kwargs) -> np.ndarray: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, we are trying to mimic pandas (https://pandas.pydata.org/pandas-docs/version/2.1.2/reference/api/pandas.Index.to_numpy.html), so it is very important to restrict use positionally.
Suggested change
Otherwise, someone might have some pandas code that does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||||||
return self.to_pandas(allow_large_results=allow_large_results).to_numpy( | ||||||
dtype, **kwargs | ||||||
) | ||||||
|
||||||
__array__ = to_numpy | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's less necessary in this context, since we aren't trying to mimic pandas, but I'd still like to avoid using this parameter positionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.