MCPcopy
hub / github.com/pandas-dev/pandas / test_series

Method test_series

pandas/tests/io/json/test_ujson.py:840–870  ·  view source on GitHub ↗
(self, orient)

Source from the content-addressed store, hash-verified

838 assert ujson.ujson_loads(ujson.ujson_dumps(nested, **kwargs)) == exp
839
840 def test_series(self, orient):
841 dtype = np.int64
842 s = Series(
843 [10, 20, 30, 40, 50, 60],
844 name="series",
845 index=[6, 7, 8, 9, 10, 15],
846 dtype=dtype,
847 ).sort_values()
848 assert s.dtype == dtype
849
850 encode_kwargs = {} if orient is None else {"orient": orient}
851
852 output = ujson.ujson_loads(ujson.ujson_dumps(s, **encode_kwargs))
853 assert s.dtype == dtype
854
855 if orient == "split":
856 dec = _clean_dict(output)
857 output = Series(**dec)
858 else:
859 output = Series(output)
860
861 if orient in (None, "index"):
862 s.name = None
863 output = output.sort_values()
864 s.index = ["6", "7", "8", "9", "10", "15"]
865 elif orient in ("records", "values"):
866 s.name = None
867 s.index = [0, 1, 2, 3, 4, 5]
868
869 assert s.dtype == dtype
870 tm.assert_series_equal(output, s)
871
872 def test_series_nested(self, orient):
873 s = Series(

Callers

nothing calls this directly

Calls 3

sort_valuesMethod · 0.95
SeriesClass · 0.90
_clean_dictFunction · 0.85

Tested by

no test coverage detected