예제 #1
0
 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",
     )
예제 #2
0
 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')
예제 #3
0
 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')
예제 #4
0
 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)
예제 #5
0
 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@",
     )
예제 #6
0
 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')
예제 #7
0
 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')
예제 #8
0
    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')
예제 #9
0
    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",
        )
예제 #10
0
 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)
예제 #11
0
 def sparse_series_dict(self):
     d = OrderedDict()
     d["b"] = 1
     d["a"] = 0
     d["c"] = 2
     return pandas.Series(d, dtype="Sparse[int]")
예제 #12
0
 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)