4
4
import collections
5
5
import datetime as dt
6
6
import gc
7
- import json
7
+ from json import loads
8
8
import operator
9
9
import pickle
10
10
import re
134
134
algorithms as algos ,
135
135
arraylike ,
136
136
indexing ,
137
- missing ,
138
137
nanops ,
139
138
sample ,
140
139
)
160
159
SingleArrayManager ,
161
160
)
162
161
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
+ )
164
167
from pandas .core .ops import align_method_FRAME
165
168
from pandas .core .reshape .concat import concat
166
169
from pandas .core .shared_docs import _shared_docs
@@ -2122,7 +2125,7 @@ def _repr_data_resource_(self):
2122
2125
2123
2126
as_json = data .to_json (orient = "table" )
2124
2127
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 )
2126
2129
2127
2130
# ----------------------------------------------------------------------
2128
2131
# I/O Methods
@@ -2410,16 +2413,16 @@ def to_json(
2410
2413
2411
2414
Examples
2412
2415
--------
2413
- >>> import json
2416
+ >>> from json import loads, dumps
2414
2417
>>> df = pd.DataFrame(
2415
2418
... [["a", "b"], ["c", "d"]],
2416
2419
... index=["row 1", "row 2"],
2417
2420
... columns=["col 1", "col 2"],
2418
2421
... )
2419
2422
2420
2423
>>> 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
2423
2426
{{
2424
2427
"columns": [
2425
2428
"col 1",
@@ -2445,8 +2448,8 @@ def to_json(
2445
2448
Note that index labels are not preserved with this encoding.
2446
2449
2447
2450
>>> 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
2450
2453
[
2451
2454
{{
2452
2455
"col 1": "a",
@@ -2461,8 +2464,8 @@ def to_json(
2461
2464
Encoding/decoding a Dataframe using ``'index'`` formatted JSON:
2462
2465
2463
2466
>>> 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
2466
2469
{{
2467
2470
"row 1": {{
2468
2471
"col 1": "a",
@@ -2477,8 +2480,8 @@ def to_json(
2477
2480
Encoding/decoding a Dataframe using ``'columns'`` formatted JSON:
2478
2481
2479
2482
>>> 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
2482
2485
{{
2483
2486
"col 1": {{
2484
2487
"row 1": "a",
@@ -2493,8 +2496,8 @@ def to_json(
2493
2496
Encoding/decoding a Dataframe using ``'values'`` formatted JSON:
2494
2497
2495
2498
>>> 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
2498
2501
[
2499
2502
[
2500
2503
"a",
@@ -2509,8 +2512,8 @@ def to_json(
2509
2512
Encoding with Table Schema:
2510
2513
2511
2514
>>> 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
2514
2517
{{
2515
2518
"schema": {{
2516
2519
"fields": [
@@ -5169,7 +5172,7 @@ def reindex(self: NDFrameT, *args, **kwargs) -> NDFrameT:
5169
5172
5170
5173
# construct the args
5171
5174
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 ))
5173
5176
level = kwargs .pop ("level" , None )
5174
5177
copy = kwargs .pop ("copy" , None )
5175
5178
limit = kwargs .pop ("limit" , None )
@@ -9201,7 +9204,7 @@ def align(
9201
9204
4 600.0 700.0 800.0 900.0 NaN
9202
9205
"""
9203
9206
9204
- method = missing . clean_fill_method (method )
9207
+ method = clean_fill_method (method )
9205
9208
9206
9209
if broadcast_axis == 1 and self .ndim != other .ndim :
9207
9210
if isinstance (self , ABCSeries ):
0 commit comments