Skip to content

Commit 04cc404

Browse files
DarioHettDario Hett
and
Dario Hett
authored
feat: add table to JsonSeriesOrient Literals (#482)
* feat: add `table` to JsonSeriesOrient Literals * TST: add all series.to_json orient parameters (#482) * TST: Series.to_json explicit orient tests * TST: Series.to_json drop unused argument * TST: series.to_json() path parameter Co-authored-by: Dario Hett <[email protected]>
1 parent 2339f31 commit 04cc404

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

pandas-stubs/_typing.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ MergeHow: TypeAlias = Union[JoinHow, Literal["cross"]]
320320
JsonFrameOrient: TypeAlias = Literal[
321321
"split", "records", "index", "columns", "values", "table"
322322
]
323-
JsonSeriesOrient: TypeAlias = Literal["split", "records", "index"]
323+
JsonSeriesOrient: TypeAlias = Literal["split", "records", "index", "table"]
324324

325325
TimestampConvention: TypeAlias = Literal["start", "end", "s", "e"]
326326

tests/test_io.py

+31
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,37 @@ def test_json_series():
393393
check(assert_type(s.to_json(path), None), type(None))
394394
check(assert_type(read_json(path, typ="series"), Series), Series)
395395
check(assert_type(DF.to_json(), str), str)
396+
check(
397+
assert_type(
398+
read_json(s.to_json(orient=None), typ="series", orient=None), Series
399+
),
400+
Series,
401+
)
402+
check(
403+
assert_type(
404+
read_json(s.to_json(orient="split"), typ="series", orient="split"), Series
405+
),
406+
Series,
407+
)
408+
check(
409+
assert_type(
410+
read_json(s.to_json(orient="records"), typ="series", orient="records"),
411+
Series,
412+
),
413+
Series,
414+
)
415+
check(
416+
assert_type(
417+
read_json(s.to_json(orient="index"), typ="series", orient="index"), Series
418+
),
419+
Series,
420+
)
421+
check(
422+
assert_type(
423+
read_json(s.to_json(orient="table"), typ="series", orient="table"), Series
424+
),
425+
Series,
426+
)
396427

397428

398429
def test_json_chunk():

0 commit comments

Comments
 (0)