Skip to content

Commit 78bd864

Browse files
committed
Fix doctest errors related to new string repr, as well as other misc doctests (asof and squeeze)
1 parent 8de38e8 commit 78bd864

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pandas/core/generic.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ def squeeze(self, axis: Axis | None = None) -> Scalar | Series | DataFrame:
885885
dtype: int64
886886
887887
>>> even_primes.squeeze()
888-
np.int64(2)
888+
2
889889
890890
Squeezing objects with more than one value in every axis does nothing:
891891
@@ -943,7 +943,7 @@ def squeeze(self, axis: Axis | None = None) -> Scalar | Series | DataFrame:
943943
Squeezing all axes will project directly into a scalar:
944944
945945
>>> df_0a.squeeze()
946-
np.int64(1)
946+
1
947947
"""
948948
axes = range(self._AXIS_LEN) if axis is None else (self._get_axis_number(axis),)
949949
result = self.iloc[
@@ -1918,7 +1918,7 @@ def keys(self) -> Index:
19181918
b 2 4
19191919
c 3 8
19201920
>>> d.keys()
1921-
Index(['A', 'B'], dtype='object')
1921+
Index(['A', 'B'], dtype='str')
19221922
"""
19231923
return self._info_axis
19241924

@@ -6276,7 +6276,7 @@ def dtypes(self):
62766276
float float64
62776277
int int64
62786278
datetime datetime64[s]
6279-
string object
6279+
string str
62806280
dtype: object
62816281
"""
62826282
data = self._mgr.get_dtypes()
@@ -6838,7 +6838,7 @@ def convert_dtypes(
68386838
0 a
68396839
1 b
68406840
2 NaN
6841-
dtype: object
6841+
dtype: str
68426842
68436843
Obtain a Series with dtype ``StringDtype``.
68446844
@@ -7968,7 +7968,7 @@ def asof(self, where, subset=None):
79687968
dtype: float64
79697969
79707970
>>> s.asof(20)
7971-
np.float64(2.0)
7971+
2.0
79727972
79737973
For a sequence `where`, a Series is returned. The first value is
79747974
NaN, because the first element of `where` is before the first
@@ -7983,7 +7983,7 @@ def asof(self, where, subset=None):
79837983
NaN, even though NaN is at the index location for ``30``.
79847984
79857985
>>> s.asof(30)
7986-
np.float64(2.0)
7986+
2.0
79877987
79887988
Take all columns into consideration
79897989
@@ -8138,7 +8138,7 @@ def isna(self) -> Self:
81388138
... )
81398139
>>> df
81408140
age born name toy
8141-
0 5.0 NaT Alfred None
8141+
0 5.0 NaT Alfred NaN
81428142
1 6.0 1939-05-27 Batman Batmobile
81438143
2 NaN 1940-04-25 Joker
81448144
@@ -8211,7 +8211,7 @@ def notna(self) -> Self:
82118211
... )
82128212
>>> df
82138213
age born name toy
8214-
0 5.0 NaT Alfred None
8214+
0 5.0 NaT Alfred NaN
82158215
1 6.0 1939-05-27 Batman Batmobile
82168216
2 NaN 1940-04-25 Joker
82178217
@@ -10401,7 +10401,7 @@ def truncate(
1040110401
2 b
1040210402
3 c
1040310403
4 d
10404-
Name: A, dtype: object
10404+
Name: A, dtype: str
1040510405
1040610406
The index values in ``truncate`` can be datetimes or string
1040710407
dates.
@@ -11804,7 +11804,7 @@ def first_valid_index(self) -> Hashable:
1180411804
>>> print(df.last_valid_index())
1180511805
None
1180611806
11807-
If all elements in DataFrame are NA/null, returns None.
11807+
If all elements in DataFrame are NA/null, returns NaN.
1180811808
1180911809
>>> df = pd.DataFrame()
1181011810
>>> df

0 commit comments

Comments
 (0)