|
3 | 3 | import numpy as np |
4 | 4 | import pytest |
5 | 5 |
|
6 | | -from pandas.compat.numpy import np_version_under1p17 |
7 | | - |
8 | 6 | from pandas.core.dtypes.common import is_scalar |
9 | 7 |
|
10 | 8 | import pandas as pd |
11 | 9 | from pandas import DataFrame, Series, date_range |
12 | 10 | import pandas._testing as tm |
13 | | -import pandas.core.common as com |
14 | 11 |
|
15 | 12 | # ---------------------------------------------------------------------- |
16 | 13 | # Generic types test cases |
@@ -404,26 +401,6 @@ def test_sample(self): |
404 | 401 | weights_with_None[5] = 0.5 |
405 | 402 | self._compare(o.sample(n=1, axis=0, weights=weights_with_None), o.iloc[5:6]) |
406 | 403 |
|
407 | | - def test_sample_upsampling_without_replacement(self): |
408 | | - # GH27451 |
409 | | - |
410 | | - df = DataFrame({"A": list("abc")}) |
411 | | - msg = ( |
412 | | - "Replace has to be set to `True` when " |
413 | | - "upsampling the population `frac` > 1." |
414 | | - ) |
415 | | - with pytest.raises(ValueError, match=msg): |
416 | | - df.sample(frac=2, replace=False) |
417 | | - |
418 | | - def test_sample_is_copy(self): |
419 | | - # GH-27357, GH-30784: ensure the result of sample is an actual copy and |
420 | | - # doesn't track the parent dataframe / doesn't give SettingWithCopy warnings |
421 | | - df = DataFrame(np.random.randn(10, 3), columns=["a", "b", "c"]) |
422 | | - df2 = df.sample(3) |
423 | | - |
424 | | - with tm.assert_produces_warning(None): |
425 | | - df2["d"] = 1 |
426 | | - |
427 | 404 | def test_size_compat(self): |
428 | 405 | # GH8846 |
429 | 406 | # size property should be defined |
@@ -534,7 +511,7 @@ def test_pct_change(self, periods, fill_method, limit, exp): |
534 | 511 | class TestNDFrame: |
535 | 512 | # tests that don't fit elsewhere |
536 | 513 |
|
537 | | - def test_sample(sel): |
| 514 | + def test_sample(self): |
538 | 515 | # Fixes issue: 2419 |
539 | 516 | # additional specific object based tests |
540 | 517 |
|
@@ -645,29 +622,6 @@ def test_sample(sel): |
645 | 622 | with pytest.raises(ValueError): |
646 | 623 | df.sample(1, weights=s4) |
647 | 624 |
|
648 | | - @pytest.mark.parametrize( |
649 | | - "func_str,arg", |
650 | | - [ |
651 | | - ("np.array", [2, 3, 1, 0]), |
652 | | - pytest.param( |
653 | | - "np.random.MT19937", |
654 | | - 3, |
655 | | - marks=pytest.mark.skipif(np_version_under1p17, reason="NumPy<1.17"), |
656 | | - ), |
657 | | - pytest.param( |
658 | | - "np.random.PCG64", |
659 | | - 11, |
660 | | - marks=pytest.mark.skipif(np_version_under1p17, reason="NumPy<1.17"), |
661 | | - ), |
662 | | - ], |
663 | | - ) |
664 | | - def test_sample_random_state(self, func_str, arg): |
665 | | - # GH32503 |
666 | | - df = DataFrame({"col1": range(10, 20), "col2": range(20, 30)}) |
667 | | - result = df.sample(n=3, random_state=eval(func_str)(arg)) |
668 | | - expected = df.sample(n=3, random_state=com.random_state(eval(func_str)(arg))) |
669 | | - tm.assert_frame_equal(result, expected) |
670 | | - |
671 | 625 | def test_squeeze(self): |
672 | 626 | # noop |
673 | 627 | for s in [tm.makeFloatSeries(), tm.makeStringSeries(), tm.makeObjectSeries()]: |
@@ -837,34 +791,6 @@ def test_equals(self): |
837 | 791 | df2 = df1.set_index(["floats"], append=True) |
838 | 792 | assert df3.equals(df2) |
839 | 793 |
|
840 | | - def test_pipe(self): |
841 | | - df = DataFrame({"A": [1, 2, 3]}) |
842 | | - f = lambda x, y: x ** y |
843 | | - result = df.pipe(f, 2) |
844 | | - expected = DataFrame({"A": [1, 4, 9]}) |
845 | | - tm.assert_frame_equal(result, expected) |
846 | | - |
847 | | - result = df.A.pipe(f, 2) |
848 | | - tm.assert_series_equal(result, expected.A) |
849 | | - |
850 | | - def test_pipe_tuple(self): |
851 | | - df = DataFrame({"A": [1, 2, 3]}) |
852 | | - f = lambda x, y: y |
853 | | - result = df.pipe((f, "y"), 0) |
854 | | - tm.assert_frame_equal(result, df) |
855 | | - |
856 | | - result = df.A.pipe((f, "y"), 0) |
857 | | - tm.assert_series_equal(result, df.A) |
858 | | - |
859 | | - def test_pipe_tuple_error(self): |
860 | | - df = DataFrame({"A": [1, 2, 3]}) |
861 | | - f = lambda x, y: y |
862 | | - with pytest.raises(ValueError): |
863 | | - df.pipe((f, "y"), x=1, y=0) |
864 | | - |
865 | | - with pytest.raises(ValueError): |
866 | | - df.A.pipe((f, "y"), x=1, y=0) |
867 | | - |
868 | 794 | @pytest.mark.parametrize("box", [pd.Series, pd.DataFrame]) |
869 | 795 | def test_axis_classmethods(self, box): |
870 | 796 | obj = box(dtype=object) |
|
0 commit comments