def test_index_series_as_assoc(self): series_mixed = pandas.Series([1, 2, 3], index=[-1, "a", 1]) self.export_compare( series_mixed, wl=b'<|-1 -> 1, "a" -> 2, 1 -> 3|>', wxf= b"8:f\x03s\x0bAssociationf\x02s\x04RuleC\xffC\x01f\x02s\x04RuleS\x01aC\x02f\x02s\x04RuleC\x01C\x03", )
def test_index_series_as_dataset(self): series_mixed = pandas.Series([1, 2, 3], index=[-1, 'a', 1]) self.export_compare( series_mixed, wl=b'Dataset[<|-1 -> 1, "a" -> 2, 1 -> 3|>]', wxf= b'8:f\x01s\x07Datasetf\x03s\x0bAssociationf\x02s\x04RuleC\xffC\x01f\x02s\x04RuleS\x01aC\x02f\x02s\x04RuleC\x01C\x03', pandas_series_head='dataset')
def test_index_series_as_list(self): series_mixed = pandas.Series([1, 2, 3], index=[-1, 'a', 1]) self.export_compare( series_mixed, wl=b'{-1 -> 1, "a" -> 2, 1 -> 3}', wxf= b'8:f\x03s\x04Listf\x02s\x04RuleC\xffC\x01f\x02s\x04RuleS\x01aC\x02f\x02s\x04RuleC\x01C\x03', pandas_series_head='list')
def multiindex_series(self): mi = pandas.MultiIndex( levels=[["a", "b"], ["x", "y"], [0]], labels=[ [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [0, -1, 0, -1, 0, -1, 0, -1], ], ) return pandas.Series(numpy.arange(8), index=mi)
def test_index_nan_series_as_assoc(self): arr, index = self.create_numpy_data_nan() series_mixed = pandas.Series(arr, index=index) self.export_compare( series_mixed, wl= b"<|0 -> 0., 1 -> Indeterminate, 2 -> 2., 3 -> Indeterminate, 4 -> 4.|>", wxf= b"8:f\x05s\x0bAssociationf\x02s\x04RuleC\x00r\x00\x00\x00\x00\x00\x00\x00\x00f\x02s\x04RuleC\x01s\rIndeterminatef\x02s\x04RuleC\x02r\x00\x00\x00\x00\x00\x00\x00@f\x02s\x04RuleC\x03s\rIndeterminatef\x02s\x04RuleC\x04r\x00\x00\x00\x00\x00\x00\x10@", )
def test_index_series_as_dataset(self): arr, index = self.create_numpy_data_nan() series_mixed = pandas.Series(arr, index=index) self.export_compare( series_mixed, wl= b'Dataset[<|0 -> 0., 1 -> Indeterminate, 2 -> 2., 3 -> Indeterminate, 4 -> 4.|>]', wxf= b'8:f\x01s\x07Datasetf\x05s\x0bAssociationf\x02s\x04RuleC\x00r\x00\x00\x00\x00\x00\x00\x00\x00f\x02s\x04RuleC\x01s\rIndeterminatef\x02s\x04RuleC\x02r\x00\x00\x00\x00\x00\x00\x00@f\x02s\x04RuleC\x03s\rIndeterminatef\x02s\x04RuleC\x04r\x00\x00\x00\x00\x00\x00\x10@', pandas_series_head='dataset')
def test_index_series_as_list(self): arr, index = self.create_numpy_data_nan() series_mixed = pandas.Series(arr, index=index) self.export_compare( series_mixed, wl= b'{0 -> 0., 1 -> Indeterminate, 2 -> 2., 3 -> Indeterminate, 4 -> 4.}', wxf= b'8:f\x05s\x04Listf\x02s\x04RuleC\x00r\x00\x00\x00\x00\x00\x00\x00\x00f\x02s\x04RuleC\x01s\rIndeterminatef\x02s\x04RuleC\x02r\x00\x00\x00\x00\x00\x00\x00@f\x02s\x04RuleC\x03s\rIndeterminatef\x02s\x04RuleC\x04r\x00\x00\x00\x00\x00\x00\x10@', pandas_series_head='list')
def test_empty_series(self): o = pandas.Series([]) self.export_compare(o, wl=b'<||>', wxf=b'8:f\x00s\x0bAssociation', pandas_series_head='association') self.export_compare(o, wl=b'{}', wxf=b'8:f\x00s\x04List', pandas_series_head='list') self.export_compare(o, wl=b'Dataset[<||>]', wxf=b'8:f\x01s\x07Datasetf\x00s\x0bAssociation', pandas_series_head='dataset')
def test_empty_series(self): o = pandas.Series([]) self.export_compare(o, wl=b"<||>", wxf=b"8:f\x00s\x0bAssociation", pandas_series_head="association") self.export_compare(o, wl=b"{}", wxf=b"8:f\x00s\x04List", pandas_series_head="list") self.export_compare( o, wl=b"Dataset[<||>]", wxf=b"8:f\x01s\x07Datasetf\x00s\x0bAssociation", pandas_series_head="dataset", )
def sparse_series_dict_indexed(self): constructor_dict = {1: 1.0} index = [0, 1, 2] # Series with index passed in series = pandas.Series(constructor_dict) return pandas.SparseSeries(series, index=index)
def sparse_series_dict(self): d = OrderedDict() d["b"] = 1 d["a"] = 0 d["c"] = 2 return pandas.Series(d, dtype="Sparse[int]")
def multiindex_series(self): mi = pandas.MultiIndex(levels=[['a', 'b'], ['x', 'y'], [0]], labels=[[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [0, -1, 0, -1, 0, -1, 0, -1]]) return pandas.Series(numpy.arange(8), index=mi)