Skip to content

Commit a0634c9

Browse files
DOC: fix EX03 errors in docstrings - pandas.core.resample.Resampler.interpolate, pandas.pivot, pandas.merge_asof, pandas.wide_to_long (#56868)
1 parent d9849df commit a0634c9

File tree

3 files changed

+34
-38
lines changed

3 files changed

+34
-38
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8989
pandas.read_parquet \
9090
pandas.DataFrame.to_sql \
9191
pandas.read_stata \
92-
pandas.core.resample.Resampler.interpolate \
9392
pandas.plotting.scatter_matrix \
94-
pandas.pivot \
95-
pandas.merge_asof \
96-
pandas.wide_to_long \
9793
pandas.Index.rename \
9894
pandas.Index.droplevel \
9995
pandas.Index.isin \

pandas/core/reshape/melt.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def wide_to_long(
295295
... "B1970" : {0 : 2.5, 1 : 1.2, 2 : .7},
296296
... "B1980" : {0 : 3.2, 1 : 1.3, 2 : .1},
297297
... "X" : dict(zip(range(3), np.random.randn(3)))
298-
... })
298+
... })
299299
>>> df["id"] = df.index
300300
>>> df
301301
A1970 A1980 B1970 B1980 X id
@@ -332,8 +332,8 @@ def wide_to_long(
332332
6 3 1 2.2 3.3
333333
7 3 2 2.3 3.4
334334
8 3 3 2.1 2.9
335-
>>> l = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age')
336-
>>> l
335+
>>> long_format = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age')
336+
>>> long_format
337337
... # doctest: +NORMALIZE_WHITESPACE
338338
ht
339339
famid birth age
@@ -358,9 +358,9 @@ def wide_to_long(
358358
359359
Going from long back to wide just takes some creative use of `unstack`
360360
361-
>>> w = l.unstack()
362-
>>> w.columns = w.columns.map('{0[0]}{0[1]}'.format)
363-
>>> w.reset_index()
361+
>>> wide_format = long_format.unstack()
362+
>>> wide_format.columns = wide_format.columns.map('{0[0]}{0[1]}'.format)
363+
>>> wide_format.reset_index()
364364
famid birth ht1 ht2
365365
0 1 1 2.8 3.4
366366
1 1 2 2.9 3.8
@@ -381,7 +381,7 @@ def wide_to_long(
381381
... 'B(weekly)-2011': np.random.rand(3),
382382
... 'X' : np.random.randint(3, size=3)})
383383
>>> df['id'] = df.index
384-
>>> df # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
384+
>>> df # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
385385
A(weekly)-2010 A(weekly)-2011 B(weekly)-2010 B(weekly)-2011 X id
386386
0 0.548814 0.544883 0.437587 0.383442 0 0
387387
1 0.715189 0.423655 0.891773 0.791725 1 1
@@ -430,9 +430,9 @@ def wide_to_long(
430430
7 3 2 2.3 3.4
431431
8 3 3 2.1 2.9
432432
433-
>>> l = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age',
434-
... sep='_', suffix=r'\w+')
435-
>>> l
433+
>>> long_format = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age',
434+
... sep='_', suffix=r'\w+')
435+
>>> long_format
436436
... # doctest: +NORMALIZE_WHITESPACE
437437
ht
438438
famid birth age

pandas/core/reshape/merge.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,17 @@ def merge_asof(
601601
... pd.Timestamp("2016-05-25 13:30:00.075")
602602
... ],
603603
... "ticker": [
604-
... "GOOG",
605-
... "MSFT",
606-
... "MSFT",
607-
... "MSFT",
608-
... "GOOG",
609-
... "AAPL",
610-
... "GOOG",
611-
... "MSFT"
612-
... ],
613-
... "bid": [720.50, 51.95, 51.97, 51.99, 720.50, 97.99, 720.50, 52.01],
614-
... "ask": [720.93, 51.96, 51.98, 52.00, 720.93, 98.01, 720.88, 52.03]
604+
... "GOOG",
605+
... "MSFT",
606+
... "MSFT",
607+
... "MSFT",
608+
... "GOOG",
609+
... "AAPL",
610+
... "GOOG",
611+
... "MSFT"
612+
... ],
613+
... "bid": [720.50, 51.95, 51.97, 51.99, 720.50, 97.99, 720.50, 52.01],
614+
... "ask": [720.93, 51.96, 51.98, 52.00, 720.93, 98.01, 720.88, 52.03]
615615
... }
616616
... )
617617
>>> quotes
@@ -626,19 +626,19 @@ def merge_asof(
626626
7 2016-05-25 13:30:00.075 MSFT 52.01 52.03
627627
628628
>>> trades = pd.DataFrame(
629-
... {
630-
... "time": [
631-
... pd.Timestamp("2016-05-25 13:30:00.023"),
632-
... pd.Timestamp("2016-05-25 13:30:00.038"),
633-
... pd.Timestamp("2016-05-25 13:30:00.048"),
634-
... pd.Timestamp("2016-05-25 13:30:00.048"),
635-
... pd.Timestamp("2016-05-25 13:30:00.048")
636-
... ],
637-
... "ticker": ["MSFT", "MSFT", "GOOG", "GOOG", "AAPL"],
638-
... "price": [51.95, 51.95, 720.77, 720.92, 98.0],
639-
... "quantity": [75, 155, 100, 100, 100]
640-
... }
641-
... )
629+
... {
630+
... "time": [
631+
... pd.Timestamp("2016-05-25 13:30:00.023"),
632+
... pd.Timestamp("2016-05-25 13:30:00.038"),
633+
... pd.Timestamp("2016-05-25 13:30:00.048"),
634+
... pd.Timestamp("2016-05-25 13:30:00.048"),
635+
... pd.Timestamp("2016-05-25 13:30:00.048")
636+
... ],
637+
... "ticker": ["MSFT", "MSFT", "GOOG", "GOOG", "AAPL"],
638+
... "price": [51.95, 51.95, 720.77, 720.92, 98.0],
639+
... "quantity": [75, 155, 100, 100, 100]
640+
... }
641+
... )
642642
>>> trades
643643
time ticker price quantity
644644
0 2016-05-25 13:30:00.023 MSFT 51.95 75

0 commit comments

Comments
 (0)