Skip to content

Commit 4d0a436

Browse files
authored
STYLE: #49656 - generic.py (#49960)
* Update format.py * Update format.py 9.99/10 * Update generic.py * Return format.py * Update generic.py * Update generic.py based on request change * Done pre-commit
1 parent c09ac01 commit 4d0a436

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

pandas/core/generic.py

+22-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import collections
55
import datetime as dt
66
import gc
7-
import json
7+
from json import loads
88
import operator
99
import pickle
1010
import re
@@ -134,7 +134,6 @@
134134
algorithms as algos,
135135
arraylike,
136136
indexing,
137-
missing,
138137
nanops,
139138
sample,
140139
)
@@ -160,7 +159,11 @@
160159
SingleArrayManager,
161160
)
162161
from pandas.core.internals.construction import mgr_to_mgr
163-
from pandas.core.missing import find_valid_index
162+
from pandas.core.missing import (
163+
clean_fill_method,
164+
clean_reindex_fill_method,
165+
find_valid_index,
166+
)
164167
from pandas.core.ops import align_method_FRAME
165168
from pandas.core.reshape.concat import concat
166169
from pandas.core.shared_docs import _shared_docs
@@ -2122,7 +2125,7 @@ def _repr_data_resource_(self):
21222125

21232126
as_json = data.to_json(orient="table")
21242127
as_json = cast(str, as_json)
2125-
return json.loads(as_json, object_pairs_hook=collections.OrderedDict)
2128+
return loads(as_json, object_pairs_hook=collections.OrderedDict)
21262129

21272130
# ----------------------------------------------------------------------
21282131
# I/O Methods
@@ -2410,16 +2413,16 @@ def to_json(
24102413
24112414
Examples
24122415
--------
2413-
>>> import json
2416+
>>> from json import loads, dumps
24142417
>>> df = pd.DataFrame(
24152418
... [["a", "b"], ["c", "d"]],
24162419
... index=["row 1", "row 2"],
24172420
... columns=["col 1", "col 2"],
24182421
... )
24192422
24202423
>>> result = df.to_json(orient="split")
2421-
>>> parsed = json.loads(result)
2422-
>>> json.dumps(parsed, indent=4) # doctest: +SKIP
2424+
>>> parsed = loads(result)
2425+
>>> dumps(parsed, indent=4) # doctest: +SKIP
24232426
{{
24242427
"columns": [
24252428
"col 1",
@@ -2445,8 +2448,8 @@ def to_json(
24452448
Note that index labels are not preserved with this encoding.
24462449
24472450
>>> result = df.to_json(orient="records")
2448-
>>> parsed = json.loads(result)
2449-
>>> json.dumps(parsed, indent=4) # doctest: +SKIP
2451+
>>> parsed = loads(result)
2452+
>>> dumps(parsed, indent=4) # doctest: +SKIP
24502453
[
24512454
{{
24522455
"col 1": "a",
@@ -2461,8 +2464,8 @@ def to_json(
24612464
Encoding/decoding a Dataframe using ``'index'`` formatted JSON:
24622465
24632466
>>> result = df.to_json(orient="index")
2464-
>>> parsed = json.loads(result)
2465-
>>> json.dumps(parsed, indent=4) # doctest: +SKIP
2467+
>>> parsed = loads(result)
2468+
>>> dumps(parsed, indent=4) # doctest: +SKIP
24662469
{{
24672470
"row 1": {{
24682471
"col 1": "a",
@@ -2477,8 +2480,8 @@ def to_json(
24772480
Encoding/decoding a Dataframe using ``'columns'`` formatted JSON:
24782481
24792482
>>> result = df.to_json(orient="columns")
2480-
>>> parsed = json.loads(result)
2481-
>>> json.dumps(parsed, indent=4) # doctest: +SKIP
2483+
>>> parsed = loads(result)
2484+
>>> dumps(parsed, indent=4) # doctest: +SKIP
24822485
{{
24832486
"col 1": {{
24842487
"row 1": "a",
@@ -2493,8 +2496,8 @@ def to_json(
24932496
Encoding/decoding a Dataframe using ``'values'`` formatted JSON:
24942497
24952498
>>> result = df.to_json(orient="values")
2496-
>>> parsed = json.loads(result)
2497-
>>> json.dumps(parsed, indent=4) # doctest: +SKIP
2499+
>>> parsed = loads(result)
2500+
>>> dumps(parsed, indent=4) # doctest: +SKIP
24982501
[
24992502
[
25002503
"a",
@@ -2509,8 +2512,8 @@ def to_json(
25092512
Encoding with Table Schema:
25102513
25112514
>>> result = df.to_json(orient="table")
2512-
>>> parsed = json.loads(result)
2513-
>>> json.dumps(parsed, indent=4) # doctest: +SKIP
2515+
>>> parsed = loads(result)
2516+
>>> dumps(parsed, indent=4) # doctest: +SKIP
25142517
{{
25152518
"schema": {{
25162519
"fields": [
@@ -5169,7 +5172,7 @@ def reindex(self: NDFrameT, *args, **kwargs) -> NDFrameT:
51695172

51705173
# construct the args
51715174
axes, kwargs = self._construct_axes_from_arguments(args, kwargs)
5172-
method = missing.clean_reindex_fill_method(kwargs.pop("method", None))
5175+
method = clean_reindex_fill_method(kwargs.pop("method", None))
51735176
level = kwargs.pop("level", None)
51745177
copy = kwargs.pop("copy", None)
51755178
limit = kwargs.pop("limit", None)
@@ -9201,7 +9204,7 @@ def align(
92019204
4 600.0 700.0 800.0 900.0 NaN
92029205
"""
92039206

9204-
method = missing.clean_fill_method(method)
9207+
method = clean_fill_method(method)
92059208

92069209
if broadcast_axis == 1 and self.ndim != other.ndim:
92079210
if isinstance(self, ABCSeries):

0 commit comments

Comments
 (0)