Skip to content

Commit 5c0e8a3

Browse files
committed
Annotated to_json in pandas.core.generic
1 parent 592be66 commit 5c0e8a3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

pandas/core/generic.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pickle
88
import re
99
from textwrap import dedent
10-
from typing import Callable, Dict, FrozenSet, List, Optional, Set
10+
from typing import Any, Callable, Dict, FrozenSet, List, Optional, Set, Union
1111
import warnings
1212
import weakref
1313

@@ -50,7 +50,7 @@
5050
from pandas.core.dtypes.missing import isna, notna
5151

5252
import pandas as pd
53-
from pandas._typing import Dtype
53+
from pandas._typing import Dtype, FilePathOrBuffer
5454
from pandas.core import missing, nanops
5555
import pandas.core.algorithms as algos
5656
from pandas.core.base import PandasObject, SelectionMixin
@@ -122,6 +122,9 @@ def _single_replace(self, to_replace, method, inplace, limit):
122122
return result
123123

124124

125+
bool_t = bool # Need alias because NDFrame has def bool:
126+
127+
125128
class NDFrame(PandasObject, SelectionMixin):
126129
"""
127130
N-dimensional analogue of DataFrame. Store multi-dimensional in a
@@ -2239,18 +2242,18 @@ def to_excel(
22392242

22402243
def to_json(
22412244
self,
2242-
path_or_buf=None,
2243-
orient=None,
2244-
date_format=None,
2245-
double_precision=10,
2246-
force_ascii=True,
2247-
date_unit="ms",
2248-
default_handler=None,
2249-
lines=False,
2250-
compression="infer",
2251-
index=True,
2252-
indent=0,
2253-
):
2245+
path_or_buf: Optional[FilePathOrBuffer] = None,
2246+
orient: Optional[str] = None,
2247+
date_format: Optional[str] = None,
2248+
double_precision: int = 10,
2249+
force_ascii: bool_t = True,
2250+
date_unit: str = "ms",
2251+
default_handler: Optional[Callable[[Any], Union[int, str, List, Dict]]] = None,
2252+
lines: bool_t = False,
2253+
compression: Optional[str] = "infer",
2254+
index: bool_t = True,
2255+
indent: int = 0,
2256+
) -> Optional[str]:
22542257
"""
22552258
Convert the object to a JSON string.
22562259

0 commit comments

Comments
 (0)