Skip to content

Commit 930c8a4

Browse files
DOC: fix doctests for datetimelike.py files for the new string dtype (#61911)
1 parent 8de38e8 commit 930c8a4

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
17781778
>>> rng.strftime("%%B %%d, %%Y, %%r")
17791779
Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
17801780
'March 10, 2018, 09:00:02 AM'],
1781-
dtype='object')
1781+
dtype='str')
17821782
"""
17831783
result = self._format_native_types(date_format=date_format, na_rep=np.nan)
17841784
if using_string_dtype():

pandas/core/arrays/datetimes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,14 +1308,14 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
13081308
0 January
13091309
1 February
13101310
2 March
1311-
dtype: object
1311+
dtype: str
13121312
13131313
>>> idx = pd.date_range(start="2018-01", freq="ME", periods=3)
13141314
>>> idx
13151315
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
13161316
dtype='datetime64[ns]', freq='ME')
13171317
>>> idx.month_name()
1318-
Index(['January', 'February', 'March'], dtype='object')
1318+
Index(['January', 'February', 'March'], dtype='str')
13191319
13201320
Using the ``locale`` parameter you can set a different locale language,
13211321
for example: ``idx.month_name(locale='pt_BR.utf8')`` will return month
@@ -1326,7 +1326,7 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
13261326
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
13271327
dtype='datetime64[ns]', freq='ME')
13281328
>>> idx.month_name(locale="pt_BR.utf8") # doctest: +SKIP
1329-
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object')
1329+
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='str')
13301330
"""
13311331
values = self._local_timestamps()
13321332

@@ -1376,14 +1376,14 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
13761376
0 Monday
13771377
1 Tuesday
13781378
2 Wednesday
1379-
dtype: object
1379+
dtype: str
13801380
13811381
>>> idx = pd.date_range(start="2018-01-01", freq="D", periods=3)
13821382
>>> idx
13831383
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
13841384
dtype='datetime64[ns]', freq='D')
13851385
>>> idx.day_name()
1386-
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')
1386+
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='str')
13871387
13881388
Using the ``locale`` parameter you can set a different locale language,
13891389
for example: ``idx.day_name(locale='pt_BR.utf8')`` will return day
@@ -1394,7 +1394,7 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
13941394
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
13951395
dtype='datetime64[ns]', freq='D')
13961396
>>> idx.day_name(locale="pt_BR.utf8") # doctest: +SKIP
1397-
Index(['Segunda', 'Terça', 'Quarta'], dtype='object')
1397+
Index(['Segunda', 'Terça', 'Quarta'], dtype='str')
13981398
"""
13991399
values = self._local_timestamps()
14001400

pandas/core/indexes/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ def astype(self, dtype: Dtype, copy: bool = True):
12091209
--------
12101210
>>> idx = pd.Index(['a', 'b', 'c'])
12111211
>>> idx.take([2, 2, 1, 2])
1212-
Index(['c', 'c', 'b', 'c'], dtype='object')
1212+
Index(['c', 'c', 'b', 'c'], dtype='str')
12131213
"""
12141214

12151215
@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
@@ -6862,11 +6862,11 @@ def delete(
68626862
--------
68636863
>>> idx = pd.Index(["a", "b", "c"])
68646864
>>> idx.delete(1)
6865-
Index(['a', 'c'], dtype='object')
6865+
Index(['a', 'c'], dtype='str')
68666866
68676867
>>> idx = pd.Index(["a", "b", "c"])
68686868
>>> idx.delete([0, 2])
6869-
Index(['b'], dtype='object')
6869+
Index(['b'], dtype='str')
68706870
"""
68716871
values = self._values
68726872
res_values: ArrayLike
@@ -6906,7 +6906,7 @@ def insert(self, loc: int, item) -> Index:
69066906
--------
69076907
>>> idx = pd.Index(["a", "b", "c"])
69086908
>>> idx.insert(1, "x")
6909-
Index(['a', 'x', 'b', 'c'], dtype='object')
6909+
Index(['a', 'x', 'b', 'c'], dtype='str')
69106910
"""
69116911
item = lib.item_from_zerodim(item)
69126912
if is_valid_na_for_dtype(item, self.dtype) and self.dtype != object:

0 commit comments

Comments
 (0)