Пример #1
0
 def test_serialize_kwargs_work_as_expected(self, input_dataframe):
     pd = pytest.importorskip("pandas", reason="Pandas not installed")
     serializer = PandasSerializer("csv",
                                   serialize_kwargs={
                                       "sep": ":",
                                       "index": False
                                   })
     serialized = serializer.serialize(input_dataframe)
     deserialized = serializer.deserialize(serialized)
     expected = pd.DataFrame({"one:two": ["1:4", "2:5", "3:6"]})
     pd.testing.assert_frame_equal(expected, deserialized)
Пример #2
0
 def test_deserialize_kwargs_work_as_expected(self, input_dataframe):
     pd = pytest.importorskip("pandas", reason="Pandas not installed")
     np = pytest.importorskip("numpy", reason="numpy not installed")
     serializer = PandasSerializer("csv",
                                   deserialize_kwargs={"na_values": [3, 5]})
     serialized = serializer.serialize(input_dataframe)
     deserialized = serializer.deserialize(serialized)
     expected = pd.DataFrame({
         "Unnamed: 0": [0, 1, 2],
         "one": [1, 2, np.nan],
         "two": [4, np.nan, 6]
     })
     pd.testing.assert_frame_equal(expected, deserialized)