Skip to content

Commit ebd598a

Browse files
nixphixjreback
authored andcommitted
DOC: fix warnings in docstrings examples (#24525) (#24642)
1 parent d106e99 commit ebd598a

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

pandas/core/arrays/datetimes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ def tz_convert(self, tz):
766766
With the `tz` parameter, we can change the DatetimeIndex
767767
to other time zones:
768768
769-
>>> dti = pd.DatetimeIndex(start='2014-08-01 09:00',
770-
... freq='H', periods=3, tz='Europe/Berlin')
769+
>>> dti = pd.date_range(start='2014-08-01 09:00',
770+
... freq='H', periods=3, tz='Europe/Berlin')
771771
772772
>>> dti
773773
DatetimeIndex(['2014-08-01 09:00:00+02:00',
@@ -784,8 +784,8 @@ def tz_convert(self, tz):
784784
With the ``tz=None``, we can remove the timezone (after converting
785785
to UTC if necessary):
786786
787-
>>> dti = pd.DatetimeIndex(start='2014-08-01 09:00',freq='H',
788-
... periods=3, tz='Europe/Berlin')
787+
>>> dti = pd.date_range(start='2014-08-01 09:00',freq='H',
788+
... periods=3, tz='Europe/Berlin')
789789
790790
>>> dti
791791
DatetimeIndex(['2014-08-01 09:00:00+02:00',
@@ -1037,8 +1037,8 @@ def normalize(self):
10371037
10381038
Examples
10391039
--------
1040-
>>> idx = pd.DatetimeIndex(start='2014-08-01 10:00', freq='H',
1041-
... periods=3, tz='Asia/Calcutta')
1040+
>>> idx = pd.date_range(start='2014-08-01 10:00', freq='H',
1041+
... periods=3, tz='Asia/Calcutta')
10421042
>>> idx
10431043
DatetimeIndex(['2014-08-01 10:00:00+05:30',
10441044
'2014-08-01 11:00:00+05:30',
@@ -1164,7 +1164,7 @@ def month_name(self, locale=None):
11641164
11651165
Examples
11661166
--------
1167-
>>> idx = pd.DatetimeIndex(start='2018-01', freq='M', periods=3)
1167+
>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
11681168
>>> idx
11691169
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
11701170
dtype='datetime64[ns]', freq='M')
@@ -1200,7 +1200,7 @@ def day_name(self, locale=None):
12001200
12011201
Examples
12021202
--------
1203-
>>> idx = pd.DatetimeIndex(start='2018-01-01', freq='D', periods=3)
1203+
>>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
12041204
>>> idx
12051205
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
12061206
dtype='datetime64[ns]', freq='D')

pandas/core/generic.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4433,8 +4433,8 @@ def _reindex_multi(self, axes, copy, fill_value):
44334433
num_legs num_wings
44344434
dog 4 0
44354435
hawk 2 2
4436-
>>> df.reindex_axis(['num_wings', 'num_legs', 'num_heads'],
4437-
... axis='columns')
4436+
>>> df.reindex(['num_wings', 'num_legs', 'num_heads'],
4437+
... axis='columns')
44384438
num_wings num_legs num_heads
44394439
dog 0 4 NaN
44404440
hawk 2 2 NaN
@@ -7352,19 +7352,19 @@ def clip_upper(self, threshold, axis=None, inplace=False):
73527352
4 5
73537353
dtype: int64
73547354
7355-
>>> s.clip_upper(3)
7355+
>>> s.clip(upper=3)
73567356
0 1
73577357
1 2
73587358
2 3
73597359
3 3
73607360
4 3
73617361
dtype: int64
73627362
7363-
>>> t = [5, 4, 3, 2, 1]
7364-
>>> t
7363+
>>> elemwise_thresholds = [5, 4, 3, 2, 1]
7364+
>>> elemwise_thresholds
73657365
[5, 4, 3, 2, 1]
73667366
7367-
>>> s.clip_upper(t)
7367+
>>> s.clip(upper=elemwise_thresholds)
73687368
0 1
73697369
1 2
73707370
2 3
@@ -7428,7 +7428,7 @@ def clip_lower(self, threshold, axis=None, inplace=False):
74287428
Series single threshold clipping:
74297429
74307430
>>> s = pd.Series([5, 6, 7, 8, 9])
7431-
>>> s.clip_lower(8)
7431+
>>> s.clip(lower=8)
74327432
0 8
74337433
1 8
74347434
2 8
@@ -7440,7 +7440,7 @@ def clip_lower(self, threshold, axis=None, inplace=False):
74407440
should be the same length as the Series.
74417441
74427442
>>> elemwise_thresholds = [4, 8, 7, 2, 5]
7443-
>>> s.clip_lower(elemwise_thresholds)
7443+
>>> s.clip(lower=elemwise_thresholds)
74447444
0 5
74457445
1 8
74467446
2 7
@@ -7457,7 +7457,7 @@ def clip_lower(self, threshold, axis=None, inplace=False):
74577457
1 3 4
74587458
2 5 6
74597459
7460-
>>> df.clip_lower(3)
7460+
>>> df.clip(lower=3)
74617461
A B
74627462
0 3 3
74637463
1 3 4
@@ -7466,7 +7466,7 @@ def clip_lower(self, threshold, axis=None, inplace=False):
74667466
Or to an array of values. By default, `threshold` should be the same
74677467
shape as the DataFrame.
74687468
7469-
>>> df.clip_lower(np.array([[3, 4], [2, 2], [6, 2]]))
7469+
>>> df.clip(lower=np.array([[3, 4], [2, 2], [6, 2]]))
74707470
A B
74717471
0 3 4
74727472
1 3 4
@@ -7476,13 +7476,13 @@ def clip_lower(self, threshold, axis=None, inplace=False):
74767476
`threshold` should be the same length as the axis specified by
74777477
`axis`.
74787478
7479-
>>> df.clip_lower([3, 3, 5], axis='index')
7479+
>>> df.clip(lower=[3, 3, 5], axis='index')
74807480
A B
74817481
0 3 3
74827482
1 3 4
74837483
2 5 6
74847484
7485-
>>> df.clip_lower([4, 5], axis='columns')
7485+
>>> df.clip(lower=[4, 5], axis='columns')
74867486
A B
74877487
0 4 5
74887488
1 4 5

0 commit comments

Comments
 (0)