Skip to content

DOC: fix doctests for datetimelike.py files for the new string dtype #61911

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
>>> rng.strftime("%%B %%d, %%Y, %%r")
Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
'March 10, 2018, 09:00:02 AM'],
dtype='object')
dtype='str')
"""
result = self._format_native_types(date_format=date_format, na_rep=np.nan)
if using_string_dtype():
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,14 +1308,14 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
0 January
1 February
2 March
dtype: object
dtype: str

>>> idx = pd.date_range(start="2018-01", freq="ME", periods=3)
>>> idx
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
dtype='datetime64[ns]', freq='ME')
>>> idx.month_name()
Index(['January', 'February', 'March'], dtype='object')
Index(['January', 'February', 'March'], dtype='str')

Using the ``locale`` parameter you can set a different locale language,
for example: ``idx.month_name(locale='pt_BR.utf8')`` will return month
Expand All @@ -1326,7 +1326,7 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
dtype='datetime64[ns]', freq='ME')
>>> idx.month_name(locale="pt_BR.utf8") # doctest: +SKIP
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object')
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='str')
"""
values = self._local_timestamps()

Expand Down Expand Up @@ -1376,14 +1376,14 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
0 Monday
1 Tuesday
2 Wednesday
dtype: object
dtype: str

>>> idx = pd.date_range(start="2018-01-01", freq="D", periods=3)
>>> idx
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
dtype='datetime64[ns]', freq='D')
>>> idx.day_name()
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='str')

Using the ``locale`` parameter you can set a different locale language,
for example: ``idx.day_name(locale='pt_BR.utf8')`` will return day
Expand All @@ -1394,7 +1394,7 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
dtype='datetime64[ns]', freq='D')
>>> idx.day_name(locale="pt_BR.utf8") # doctest: +SKIP
Index(['Segunda', 'Terça', 'Quarta'], dtype='object')
Index(['Segunda', 'Terça', 'Quarta'], dtype='str')
"""
values = self._local_timestamps()

Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ def astype(self, dtype: Dtype, copy: bool = True):
--------
>>> idx = pd.Index(['a', 'b', 'c'])
>>> idx.take([2, 2, 1, 2])
Index(['c', 'c', 'b', 'c'], dtype='object')
Index(['c', 'c', 'b', 'c'], dtype='str')
"""

@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
Expand Down Expand Up @@ -6862,11 +6862,11 @@ def delete(
--------
>>> idx = pd.Index(["a", "b", "c"])
>>> idx.delete(1)
Index(['a', 'c'], dtype='object')
Index(['a', 'c'], dtype='str')

>>> idx = pd.Index(["a", "b", "c"])
>>> idx.delete([0, 2])
Index(['b'], dtype='object')
Index(['b'], dtype='str')
"""
values = self._values
res_values: ArrayLike
Expand Down Expand Up @@ -6906,7 +6906,7 @@ def insert(self, loc: int, item) -> Index:
--------
>>> idx = pd.Index(["a", "b", "c"])
>>> idx.insert(1, "x")
Index(['a', 'x', 'b', 'c'], dtype='object')
Index(['a', 'x', 'b', 'c'], dtype='str')
"""
item = lib.item_from_zerodim(item)
if is_valid_na_for_dtype(item, self.dtype) and self.dtype != object:
Expand Down
Loading