Skip to content

Commit d356286

Browse files
Merge branch 'main' into patch-1
2 parents 9c9a61c + 82449b9 commit d356286

File tree

9 files changed

+70
-86
lines changed

9 files changed

+70
-86
lines changed

ci/code_checks.sh

-19
Original file line numberDiff line numberDiff line change
@@ -76,41 +76,25 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7676
pandas.errors.DatabaseError \
7777
pandas.errors.IndexingError \
7878
pandas.errors.InvalidColumnName \
79-
pandas.errors.PossibleDataLossError \
80-
pandas.errors.PossiblePrecisionLoss \
81-
pandas.errors.SettingWithCopyError \
8279
pandas.errors.SettingWithCopyWarning \
8380
pandas.errors.SpecificationError \
8481
pandas.errors.UndefinedVariableError \
85-
pandas.errors.ValueLabelTypeMismatch \
8682
pandas.Timestamp.ceil \
8783
pandas.Timestamp.floor \
8884
pandas.Timestamp.round \
89-
pandas.ExcelWriter \
9085
pandas.read_json \
9186
pandas.io.json.build_table_schema \
9287
pandas.io.formats.style.Styler.to_latex \
9388
pandas.read_parquet \
9489
pandas.DataFrame.to_sql \
9590
pandas.read_stata \
96-
pandas.core.resample.Resampler.interpolate \
9791
pandas.plotting.scatter_matrix \
98-
pandas.pivot \
99-
pandas.merge_asof \
100-
pandas.wide_to_long \
101-
pandas.Index.rename \
10292
pandas.Index.droplevel \
103-
pandas.Index.isin \
104-
pandas.IndexSlice \
10593
pandas.Grouper \
10694
pandas.io.formats.style.Styler.map \
10795
pandas.io.formats.style.Styler.apply_index \
10896
pandas.io.formats.style.Styler.map_index \
10997
pandas.io.formats.style.Styler.format \
110-
pandas.io.formats.style.Styler.format_index \
111-
pandas.io.formats.style.Styler.relabel_index \
112-
pandas.io.formats.style.Styler.hide \
113-
pandas.io.formats.style.Styler.set_td_classes \
11498
pandas.io.formats.style.Styler.set_tooltips \
11599
pandas.io.formats.style.Styler.set_uuid \
116100
pandas.io.formats.style.Styler.pipe \
@@ -120,9 +104,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
120104
pandas.io.formats.style.Styler.text_gradient \
121105
pandas.DataFrame.values \
122106
pandas.DataFrame.groupby \
123-
pandas.DataFrame.idxmax \
124-
pandas.DataFrame.idxmin \
125-
pandas.DataFrame.pivot \
126107
pandas.DataFrame.sort_values \
127108
pandas.DataFrame.plot.hexbin \
128109
pandas.DataFrame.plot.line \

pandas/core/indexes/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ def rename(self, name, inplace: bool = False) -> Self | None:
19531953
19541954
>>> idx = pd.MultiIndex.from_product([['python', 'cobra'],
19551955
... [2018, 2019]],
1956-
... names=['kind', 'year'])
1956+
... names=['kind', 'year'])
19571957
>>> idx
19581958
MultiIndex([('python', 2018),
19591959
('python', 2019),
@@ -6576,7 +6576,7 @@ def isin(self, values, level=None) -> npt.NDArray[np.bool_]:
65766576
65776577
Examples
65786578
--------
6579-
>>> idx = pd.Index([1,2,3])
6579+
>>> idx = pd.Index([1, 2, 3])
65806580
>>> idx
65816581
Index([1, 2, 3], dtype='int64')
65826582
@@ -6585,7 +6585,7 @@ def isin(self, values, level=None) -> npt.NDArray[np.bool_]:
65856585
>>> idx.isin([1, 4])
65866586
array([ True, False, False])
65876587
6588-
>>> midx = pd.MultiIndex.from_arrays([[1,2,3],
6588+
>>> midx = pd.MultiIndex.from_arrays([[1, 2, 3],
65896589
... ['red', 'blue', 'green']],
65906590
... names=('number', 'color'))
65916591
>>> midx

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class _IndexSlice:
121121
122122
Examples
123123
--------
124-
>>> midx = pd.MultiIndex.from_product([['A0','A1'], ['B0','B1','B2','B3']])
124+
>>> midx = pd.MultiIndex.from_product([['A0', 'A1'], ['B0', 'B1', 'B2', 'B3']])
125125
>>> columns = ['foo', 'bar']
126126
>>> dfmi = pd.DataFrame(np.arange(16).reshape((len(midx), len(columns))),
127127
... index=midx, columns=columns)

pandas/core/reshape/melt.py

+10-10
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

+24-24
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

pandas/errors/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class SettingWithCopyError(ValueError):
425425
--------
426426
>>> pd.options.mode.chained_assignment = 'raise'
427427
>>> df = pd.DataFrame({'A': [1, 1, 1, 2, 2]}, columns=['A'])
428-
>>> df.loc[0:3]['A'] = 'a' # doctest: +SKIP
428+
>>> df.loc[0:3]['A'] = 'a' # doctest: +SKIP
429429
... # SettingWithCopyError: A value is trying to be set on a copy of a...
430430
"""
431431

@@ -665,8 +665,8 @@ class PossibleDataLossError(Exception):
665665
666666
Examples
667667
--------
668-
>>> store = pd.HDFStore('my-store', 'a') # doctest: +SKIP
669-
>>> store.open("w") # doctest: +SKIP
668+
>>> store = pd.HDFStore('my-store', 'a') # doctest: +SKIP
669+
>>> store.open("w") # doctest: +SKIP
670670
... # PossibleDataLossError: Re-opening the file [my-store] with mode [a]...
671671
"""
672672

@@ -734,7 +734,7 @@ class PossiblePrecisionLoss(Warning):
734734
Examples
735735
--------
736736
>>> df = pd.DataFrame({"s": pd.Series([1, 2**53], dtype=np.int64)})
737-
>>> df.to_stata('test') # doctest: +SKIP
737+
>>> df.to_stata('test') # doctest: +SKIP
738738
... # PossiblePrecisionLoss: Column converted from int64 to float64...
739739
"""
740740

@@ -746,7 +746,7 @@ class ValueLabelTypeMismatch(Warning):
746746
Examples
747747
--------
748748
>>> df = pd.DataFrame({"categories": pd.Series(["a", 2], dtype="category")})
749-
>>> df.to_stata('test') # doctest: +SKIP
749+
>>> df.to_stata('test') # doctest: +SKIP
750750
... # ValueLabelTypeMismatch: Stata value labels (pandas categories) must be str...
751751
"""
752752

pandas/io/excel/_base.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ class ExcelWriter(Generic[_WorkbookT]):
935935
is installed otherwise `openpyxl <https://pypi.org/project/openpyxl/>`__
936936
* `odswriter <https://pypi.org/project/odswriter/>`__ for ods files
937937
938-
See ``DataFrame.to_excel`` for typical usage.
938+
See :meth:`DataFrame.to_excel` for typical usage.
939939
940940
The writer should be used as a context manager. Otherwise, call `close()` to save
941941
and close any opened file handles.
@@ -1031,7 +1031,7 @@ class ExcelWriter(Generic[_WorkbookT]):
10311031
Here, the `if_sheet_exists` parameter can be set to replace a sheet if it
10321032
already exists:
10331033
1034-
>>> with ExcelWriter(
1034+
>>> with pd.ExcelWriter(
10351035
... "path_to_file.xlsx",
10361036
... mode="a",
10371037
... engine="openpyxl",
@@ -1042,7 +1042,8 @@ class ExcelWriter(Generic[_WorkbookT]):
10421042
You can also write multiple DataFrames to a single sheet. Note that the
10431043
``if_sheet_exists`` parameter needs to be set to ``overlay``:
10441044
1045-
>>> with ExcelWriter("path_to_file.xlsx",
1045+
>>> with pd.ExcelWriter(
1046+
... "path_to_file.xlsx",
10461047
... mode="a",
10471048
... engine="openpyxl",
10481049
... if_sheet_exists="overlay",

pandas/io/formats/style.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1496,10 +1496,10 @@ def set_td_classes(self, classes: DataFrame) -> Styler:
14961496
Using `MultiIndex` columns and a `classes` `DataFrame` as a subset of the
14971497
underlying,
14981498
1499-
>>> df = pd.DataFrame([[1,2],[3,4]], index=["a", "b"],
1500-
... columns=[["level0", "level0"], ["level1a", "level1b"]])
1499+
>>> df = pd.DataFrame([[1, 2], [3, 4]], index=["a", "b"],
1500+
... columns=[["level0", "level0"], ["level1a", "level1b"]])
15011501
>>> classes = pd.DataFrame(["min-val"], index=["a"],
1502-
... columns=[["level0"],["level1a"]])
1502+
... columns=[["level0"], ["level1a"]])
15031503
>>> df.style.set_td_classes(classes) # doctest: +SKIP
15041504
15051505
Form of the output with new additional css classes,
@@ -2717,15 +2717,15 @@ def hide(
27172717
--------
27182718
Simple application hiding specific rows:
27192719
2720-
>>> df = pd.DataFrame([[1,2], [3,4], [5,6]], index=["a", "b", "c"])
2720+
>>> df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], index=["a", "b", "c"])
27212721
>>> df.style.hide(["a", "b"]) # doctest: +SKIP
27222722
0 1
27232723
c 5 6
27242724
27252725
Hide the index and retain the data values:
27262726
27272727
>>> midx = pd.MultiIndex.from_product([["x", "y"], ["a", "b", "c"]])
2728-
>>> df = pd.DataFrame(np.random.randn(6,6), index=midx, columns=midx)
2728+
>>> df = pd.DataFrame(np.random.randn(6, 6), index=midx, columns=midx)
27292729
>>> df.style.format("{:.1f}").hide() # doctest: +SKIP
27302730
x y
27312731
a b c a b c
@@ -2739,7 +2739,7 @@ def hide(
27392739
Hide specific rows in a MultiIndex but retain the index:
27402740
27412741
>>> df.style.format("{:.1f}").hide(subset=(slice(None), ["a", "c"]))
2742-
... # doctest: +SKIP
2742+
... # doctest: +SKIP
27432743
x y
27442744
a b c a b c
27452745
x b 0.7 1.0 1.3 1.5 -0.0 -0.2
@@ -2748,7 +2748,7 @@ def hide(
27482748
Hide specific rows and the index through chaining:
27492749
27502750
>>> df.style.format("{:.1f}").hide(subset=(slice(None), ["a", "c"])).hide()
2751-
... # doctest: +SKIP
2751+
... # doctest: +SKIP
27522752
x y
27532753
a b c a b c
27542754
0.7 1.0 1.3 1.5 -0.0 -0.2

0 commit comments

Comments
 (0)