-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
DOC: fix doctests for pandas/core/generic.py for new string dtype #61907
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
Merged
jorisvandenbossche
merged 3 commits into
pandas-dev:main
from
arthurlw:core/generic_repr_changes
Jul 21, 2025
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -885,7 +885,7 @@ def squeeze(self, axis: Axis | None = None) -> Scalar | Series | DataFrame: | |
dtype: int64 | ||
|
||
>>> even_primes.squeeze() | ||
np.int64(2) | ||
2 | ||
|
||
Squeezing objects with more than one value in every axis does nothing: | ||
|
||
|
@@ -943,7 +943,7 @@ def squeeze(self, axis: Axis | None = None) -> Scalar | Series | DataFrame: | |
Squeezing all axes will project directly into a scalar: | ||
|
||
>>> df_0a.squeeze() | ||
np.int64(1) | ||
1 | ||
""" | ||
axes = range(self._AXIS_LEN) if axis is None else (self._get_axis_number(axis),) | ||
result = self.iloc[ | ||
|
@@ -1918,7 +1918,7 @@ def keys(self) -> Index: | |
b 2 4 | ||
c 3 8 | ||
>>> d.keys() | ||
Index(['A', 'B'], dtype='object') | ||
Index(['A', 'B'], dtype='str') | ||
""" | ||
return self._info_axis | ||
|
||
|
@@ -6276,7 +6276,7 @@ def dtypes(self): | |
float float64 | ||
int int64 | ||
datetime datetime64[s] | ||
string object | ||
string str | ||
dtype: object | ||
""" | ||
data = self._mgr.get_dtypes() | ||
|
@@ -6838,7 +6838,7 @@ def convert_dtypes( | |
0 a | ||
1 b | ||
2 NaN | ||
dtype: object | ||
dtype: str | ||
|
||
Obtain a Series with dtype ``StringDtype``. | ||
|
||
|
@@ -7968,7 +7968,7 @@ def asof(self, where, subset=None): | |
dtype: float64 | ||
|
||
>>> s.asof(20) | ||
np.float64(2.0) | ||
2.0 | ||
|
||
For a sequence `where`, a Series is returned. The first value is | ||
NaN, because the first element of `where` is before the first | ||
|
@@ -7983,7 +7983,7 @@ def asof(self, where, subset=None): | |
NaN, even though NaN is at the index location for ``30``. | ||
|
||
>>> s.asof(30) | ||
np.float64(2.0) | ||
2.0 | ||
|
||
Take all columns into consideration | ||
|
||
|
@@ -8138,7 +8138,7 @@ def isna(self) -> Self: | |
... ) | ||
>>> df | ||
age born name toy | ||
0 5.0 NaT Alfred None | ||
0 5.0 NaT Alfred NaN | ||
1 6.0 1939-05-27 Batman Batmobile | ||
2 NaN 1940-04-25 Joker | ||
|
||
|
@@ -8211,7 +8211,7 @@ def notna(self) -> Self: | |
... ) | ||
>>> df | ||
age born name toy | ||
0 5.0 NaT Alfred None | ||
0 5.0 NaT Alfred NaN | ||
1 6.0 1939-05-27 Batman Batmobile | ||
2 NaN 1940-04-25 Joker | ||
|
||
|
@@ -10401,7 +10401,7 @@ def truncate( | |
2 b | ||
3 c | ||
4 d | ||
Name: A, dtype: object | ||
Name: A, dtype: str | ||
|
||
The index values in ``truncate`` can be datetimes or string | ||
dates. | ||
|
@@ -11804,7 +11804,7 @@ def first_valid_index(self) -> Hashable: | |
>>> print(df.last_valid_index()) | ||
None | ||
|
||
If all elements in DataFrame are NA/null, returns None. | ||
If all elements in DataFrame are NA/null, returns NaN. | ||
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. The example below still shows None? 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. Ah my bad, thanks. |
||
|
||
>>> df = pd.DataFrame() | ||
>>> df | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
With which version of numpy are you running the doctests locally?
I personally don't particularly like the
np.int64(2)
repr for in the docstrings, but I see that was recently changed in #60987 to follow the latest numpyThere 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.
Ah right, thanks for catching that. I’ll revert it