Skip to content

Commit 6537afe

Browse files
DOC: fix doctests for string dtype changes (top-level) (#61887)
1 parent 90b1c5d commit 6537afe

File tree

8 files changed

+28
-29
lines changed

8 files changed

+28
-29
lines changed

pandas/core/arrays/categorical.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,28 +794,28 @@ def categories(self) -> Index:
794794
795795
>>> ser = pd.Series(["a", "b", "c", "a"], dtype="category")
796796
>>> ser.cat.categories
797-
Index(['a', 'b', 'c'], dtype='object')
797+
Index(['a', 'b', 'c'], dtype='str')
798798
799799
>>> raw_cat = pd.Categorical(["a", "b", "c", "a"], categories=["b", "c", "d"])
800800
>>> ser = pd.Series(raw_cat)
801801
>>> ser.cat.categories
802-
Index(['b', 'c', 'd'], dtype='object')
802+
Index(['b', 'c', 'd'], dtype='str')
803803
804804
For :class:`pandas.Categorical`:
805805
806806
>>> cat = pd.Categorical(["a", "b"], ordered=True)
807807
>>> cat.categories
808-
Index(['a', 'b'], dtype='object')
808+
Index(['a', 'b'], dtype='str')
809809
810810
For :class:`pandas.CategoricalIndex`:
811811
812812
>>> ci = pd.CategoricalIndex(["a", "c", "b", "a", "c", "b"])
813813
>>> ci.categories
814-
Index(['a', 'b', 'c'], dtype='object')
814+
Index(['a', 'b', 'c'], dtype='str')
815815
816816
>>> ci = pd.CategoricalIndex(["a", "c"], categories=["c", "b", "a"])
817817
>>> ci.categories
818-
Index(['c', 'b', 'a'], dtype='object')
818+
Index(['c', 'b', 'a'], dtype='str')
819819
"""
820820
return self.dtype.categories
821821

pandas/core/dtypes/dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def categories(self) -> Index:
647647
--------
648648
>>> cat_type = pd.CategoricalDtype(categories=["a", "b"], ordered=True)
649649
>>> cat_type.categories
650-
Index(['a', 'b'], dtype='object')
650+
Index(['a', 'b'], dtype='str')
651651
"""
652652
return self._categories
653653

pandas/core/dtypes/missing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def isna(obj: object) -> bool | npt.NDArray[np.bool_] | NDFrame:
158158
159159
>>> df = pd.DataFrame([["ant", "bee", "cat"], ["dog", None, "fly"]])
160160
>>> df
161-
0 1 2
162-
0 ant bee cat
163-
1 dog None fly
161+
0 1 2
162+
0 ant bee cat
163+
1 dog NaN fly
164164
>>> pd.isna(df)
165165
0 1 2
166166
0 False False False
@@ -373,9 +373,9 @@ def notna(obj: object) -> bool | npt.NDArray[np.bool_] | NDFrame:
373373
374374
>>> df = pd.DataFrame([["ant", "bee", "cat"], ["dog", None, "fly"]])
375375
>>> df
376-
0 1 2
377-
0 ant bee cat
378-
1 dog None fly
376+
0 1 2
377+
0 ant bee cat
378+
1 dog NaN fly
379379
>>> pd.notna(df)
380380
0 1 2
381381
0 True True True

pandas/core/frame.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,7 @@ def axes(self) -> list[Index]:
10151015
--------
10161016
>>> df = pd.DataFrame({"col1": [1, 2], "col2": [3, 4]})
10171017
>>> df.axes
1018-
[RangeIndex(start=0, stop=2, step=1), Index(['col1', 'col2'],
1019-
dtype='object')]
1018+
[RangeIndex(start=0, stop=2, step=1), Index(['col1', 'col2'], dtype='str')]
10201019
"""
10211020
return [self.index, self.columns]
10221021

@@ -14070,7 +14069,7 @@ def values(self) -> np.ndarray:
1407014069
... columns=("name", "max_speed", "rank"),
1407114070
... )
1407214071
>>> df2.dtypes
14073-
name object
14072+
name str
1407414073
max_speed float64
1407514074
rank object
1407614075
dtype: object

pandas/core/groupby/groupby.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,13 +4628,13 @@ def ngroup(self, ascending: bool = True):
46284628
--------
46294629
>>> df = pd.DataFrame({"color": ["red", None, "red", "blue", "blue", "red"]})
46304630
>>> df
4631-
color
4632-
0 red
4633-
1 None
4634-
2 red
4635-
3 blue
4636-
4 blue
4637-
5 red
4631+
color
4632+
0 red
4633+
1 NaN
4634+
2 red
4635+
3 blue
4636+
4 blue
4637+
5 red
46384638
>>> df.groupby("color").ngroup()
46394639
0 1.0
46404640
1 NaN

pandas/core/indexes/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class Index(IndexOpsMixin, PandasObject):
368368
Index([1, 2, 3], dtype='int64')
369369
370370
>>> pd.Index(list("abc"))
371-
Index(['a', 'b', 'c'], dtype='object')
371+
Index(['a', 'b', 'c'], dtype='str')
372372
373373
>>> pd.Index([1, 2, 3], dtype="uint8")
374374
Index([1, 2, 3], dtype='uint8')
@@ -7599,7 +7599,7 @@ def ensure_index(index_like: Axes, copy: bool = False) -> Index:
75997599
Examples
76007600
--------
76017601
>>> ensure_index(["a", "b"])
7602-
Index(['a', 'b'], dtype='object')
7602+
Index(['a', 'b'], dtype='str')
76037603
76047604
>>> ensure_index([("a", "a"), ("b", "c")])
76057605
Index([('a', 'a'), ('b', 'c')], dtype='object')

pandas/core/interchange/from_dataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def from_dataframe(df, allow_copy: bool = True) -> pd.DataFrame:
7777
>>> df_not_necessarily_pandas = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
7878
>>> interchange_object = df_not_necessarily_pandas.__dataframe__()
7979
>>> interchange_object.column_names()
80-
Index(['A', 'B'], dtype='object')
80+
Index(['A', 'B'], dtype='str')
8181
>>> df_pandas = pd.api.interchange.from_dataframe(
8282
... interchange_object.select_columns_by_name(["A"])
8383
... )

pandas/core/reshape/concat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def concat(
258258
1 b
259259
0 c
260260
1 d
261-
dtype: object
261+
dtype: str
262262
263263
Clear the existing index and reset it in the result
264264
by setting the ``ignore_index`` option to ``True``.
@@ -268,7 +268,7 @@ def concat(
268268
1 b
269269
2 c
270270
3 d
271-
dtype: object
271+
dtype: str
272272
273273
Add a hierarchical index at the outermost level of
274274
the data with the ``keys`` option.
@@ -278,7 +278,7 @@ def concat(
278278
1 b
279279
s2 0 c
280280
1 d
281-
dtype: object
281+
dtype: str
282282
283283
Label the index keys you create with the ``names`` option.
284284
@@ -288,7 +288,7 @@ def concat(
288288
1 b
289289
s2 0 c
290290
1 d
291-
dtype: object
291+
dtype: str
292292
293293
Combine two ``DataFrame`` objects with identical columns.
294294

0 commit comments

Comments
 (0)