Пример #1
0
def series_str(data_str, index_i64):
    return Series(data_str, index_i64, np.bytes_)
Пример #2
0
def series_str_2(index_i64):
    return Series([b'abz', b'zabz', b'zab', b'  ab  ', b'a'], index_i64, np.bytes_)
Пример #3
0
    def test_head(self, series_f32):
        actual = series_f32.head(2)
        expected = Series(np.array([1, 2]), RangeIndex(2),
                          np.dtype(np.float32))

        assert_series_equal(actual, expected)
Пример #4
0
def test_empty_series_init():
    assert_series_equal(Series(), Series(np.empty(0), RangeIndex(0, 0, 1), np.dtype(np.float64)))
Пример #5
0
def df1(data_f32, index_i64_2):
    return DataFrame(OrderedDict((('a', Series(np.arange(5))), ('b', data_f32))), index_i64_2)
Пример #6
0
    def test_filter_combined(self, series_i64):
        actual = series_i64[(series_i64 != 2) & (series_i64 != 4)]
        expected = Series(np.array([1, 3, 5]), Index(np.array([0, 2, 4])),
                          np.dtype(np.int64))

        assert_series_equal(actual, expected)
Пример #7
0
 def test_init_weld_object_no_dtype(self, data_i64_lazy):
     with pytest.raises(ValueError):
         Series(data_i64_lazy)
Пример #8
0
def series_str(data_str, index_i64):
    return Series(data_str, index_i64, data_str.dtype)
Пример #9
0
    def test_evaluate(self, data_i64):
        actual = Series(data_i64)
        expected = Series(data_i64, RangeIndex(5))

        assert_series_equal(actual, expected)
Пример #10
0
    def test_init_raw_cast_type(self, data_i64, index_i64, data_f32):
        actual = Series(data_i64, index_i64, np.dtype(np.float32))
        expected = Series(data_f32, index_i64, np.dtype(np.float32))

        assert_series_equal(actual, expected)
Пример #11
0
    def test_astype(self, series_f32, data_i64, index_i64):
        actual = series_f32.astype(np.dtype(np.int64))
        expected = Series(data_i64, index_i64, np.dtype(np.int64))

        assert_series_equal(actual, expected)
Пример #12
0
    def test_op_scalar(self, operation, expected_data, index_i64, series_f32):
        actual = eval('series_f32 {} 2'.format(operation))
        expected = Series(expected_data, index_i64, np.dtype(np.float32))

        assert_series_equal(actual, expected)
Пример #13
0
    def test_op_array(self, operation, expected_data, series_f32, index_i64,
                      op_array_other):
        actual = eval('series_f32 {} op_array_other'.format(operation))
        expected = Series(expected_data, index_i64, np.dtype(np.float32))

        assert_series_equal(actual, expected)
Пример #14
0
def series_f32(data_f32, index_i64):
    return Series(data_f32, index_i64, np.dtype(np.float32))
Пример #15
0
    def test_init_list(self):
        data = [1, 2, 3]
        sr = Series(data)

        np.testing.assert_array_equal(sr.values, np.array(data))
        assert sr.dtype == np.dtype(np.int64)
Пример #16
0
def series_i64(data_i64_lazy, index_i64):
    return Series(data_i64_lazy, index_i64, np.dtype(np.int64))
Пример #17
0
 def test_init_list_wrong_dtype(self):
     data = [1, 2, 'abc']
     with pytest.raises(TypeError):
         Series(data)
Пример #18
0
def op_array_other():
    return Series(np.array([2] * 5).astype(np.float32))
Пример #19
0
    def test_comparison(self, comparison, expected_data, series_i64,
                        index_i64):
        actual = eval('series_i64 {} 2'.format(comparison))
        expected = Series(expected_data, index_i64, np.dtype(np.bool))

        assert_series_equal(actual, expected)
Пример #20
0
    def test_str_operations_other(self, func, kwargs, expected_data,
                                  series_str_2, index_i64):
        actual = getattr(series_str_2.str, func)(**kwargs)
        expected = Series(expected_data, index_i64)

        assert_series_equal(actual, expected)
Пример #21
0
    def test_aggregations(self, aggregation, expected_data, df_small):
        actual = getattr(df_small, aggregation)()
        expected = Series(expected_data,
                          Index(np.array(['a', 'b'], dtype=np.bytes_)))

        assert_series_equal(actual, expected, 5)
Пример #22
0
    def test_slice(self, series_f32):
        actual = series_f32[1:3]
        expected = Series(np.array([2, 3]), Index(np.array([1, 2])),
                          np.dtype(np.float32))

        assert_series_equal(actual, expected)
Пример #23
0
def series_unsorted(index_i64):
    return Series(np.array([5, 2, 3, 1, 4], dtype=np.float32), index_i64, np.dtype(np.float32))
Пример #24
0
    def test_tail(self, series_f32):
        actual = series_f32.tail(2)
        expected = Series(np.array([4, 5]), Index(np.array([3, 4])),
                          np.dtype(np.float32))

        assert_series_equal(actual, expected)
Пример #25
0
 def test_aggregation_empty(self, df_empty):
     assert_series_equal(df_empty.min(), Series(np.empty(0)))