Skip to content

Commit a124390

Browse files
committed
collect tests
1 parent f258a59 commit a124390

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

pandas/tests/frame/test_analytics.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,45 @@ def test_stat_op_api(self, float_frame, float_string_frame):
724724
except ImportError:
725725
pass
726726

727+
@pytest.mark.parametrize('method', ['sum', 'mean', 'prod', 'var',
728+
'std', 'skew', 'min', 'max'])
729+
def test_stat_operators_attempt_obj_array(self, method):
730+
# GH#676
731+
data = {
732+
'a': [-0.00049987540199591344, -0.0016467257772919831,
733+
0.00067695870775883013],
734+
'b': [-0, -0, 0.0],
735+
'c': [0.00031111847529610595, 0.0014902627951905339,
736+
-0.00094099200035979691]
737+
}
738+
df1 = DataFrame(data, index=['foo', 'bar', 'baz'], dtype='O')
739+
740+
df2 = DataFrame({0: [np.nan, 2], 1: [np.nan, 3],
741+
2: [np.nan, 4]}, dtype=object)
742+
743+
for df in [df1, df2]:
744+
assert df.values.dtype == np.object_
745+
result = getattr(df, method)(1)
746+
expected = getattr(df.astype('f8'), method)(1)
747+
748+
if method in ['sum', 'prod']:
749+
tm.assert_series_equal(result, expected)
750+
751+
@pytest.mark.parametrize('op', ['mean', 'std', 'var',
752+
'skew', 'kurt', 'sem'])
753+
def test_mixed_ops(self, op):
754+
# GH#16116
755+
df = DataFrame({'int': [1, 2, 3, 4],
756+
'float': [1., 2., 3., 4.],
757+
'str': ['a', 'b', 'c', 'd']})
758+
759+
result = getattr(df, op)()
760+
assert len(result) == 2
761+
762+
with pd.option_context('use_bottleneck', False):
763+
result = getattr(df, op)()
764+
assert len(result) == 2
765+
727766
def test_reduce_mixed_frame(self):
728767
# GH 6806
729768
df = DataFrame({
@@ -760,30 +799,6 @@ def test_sum(self, float_frame_with_na, mixed_float_frame):
760799
assert_stat_op_calc('sum', np.sum, mixed_float_frame.astype('float32'),
761800
check_dtype=False, check_less_precise=True)
762801

763-
@pytest.mark.parametrize('method', ['sum', 'mean', 'prod', 'var',
764-
'std', 'skew', 'min', 'max'])
765-
def test_stat_operators_attempt_obj_array(self, method):
766-
# GH 676
767-
data = {
768-
'a': [-0.00049987540199591344, -0.0016467257772919831,
769-
0.00067695870775883013],
770-
'b': [-0, -0, 0.0],
771-
'c': [0.00031111847529610595, 0.0014902627951905339,
772-
-0.00094099200035979691]
773-
}
774-
df1 = DataFrame(data, index=['foo', 'bar', 'baz'], dtype='O')
775-
776-
df2 = DataFrame({0: [np.nan, 2], 1: [np.nan, 3],
777-
2: [np.nan, 4]}, dtype=object)
778-
779-
for df in [df1, df2]:
780-
assert df.values.dtype == np.object_
781-
result = getattr(df, method)(1)
782-
expected = getattr(df.astype('f8'), method)(1)
783-
784-
if method in ['sum', 'prod']:
785-
tm.assert_series_equal(result, expected)
786-
787802
def test_mean(self, float_frame_with_na):
788803
assert_stat_op_calc('mean', np.mean, float_frame_with_na,
789804
check_dates=True)
@@ -869,21 +884,6 @@ def test_numeric_only_flag(self, meth):
869884
pytest.raises(TypeError, lambda: getattr(df2, meth)(
870885
axis=1, numeric_only=False))
871886

872-
@pytest.mark.parametrize('op', ['mean', 'std', 'var',
873-
'skew', 'kurt', 'sem'])
874-
def test_mixed_ops(self, op):
875-
# GH 16116
876-
df = DataFrame({'int': [1, 2, 3, 4],
877-
'float': [1., 2., 3., 4.],
878-
'str': ['a', 'b', 'c', 'd']})
879-
880-
result = getattr(df, op)()
881-
assert len(result) == 2
882-
883-
with pd.option_context('use_bottleneck', False):
884-
result = getattr(df, op)()
885-
assert len(result) == 2
886-
887887
def test_sem(self, float_frame_with_na, datetime_frame):
888888
alt = lambda x: np.std(x, ddof=1) / np.sqrt(len(x))
889889
assert_stat_op_calc('sem', alt, float_frame_with_na)

0 commit comments

Comments
 (0)