Skip to content

Commit f67da86

Browse files
committed
Separate tests
1 parent 9347894 commit f67da86

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

pandas/tests/frame/test_quantile.py

+29-19
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ class TestDataFrameQuantile:
1212
def test_quantile(self, datetime_frame):
1313
from numpy import percentile
1414

15-
q = datetime_frame.quantile(0.1, axis=0)
16-
assert q['A'] == percentile(datetime_frame['A'], 10)
17-
tm.assert_index_equal(q.index, datetime_frame.columns)
15+
df = datetime_frame
16+
q = df.quantile(0.1, axis=0)
17+
assert q['A'] == percentile(df['A'], 10)
18+
tm.assert_index_equal(q.index, df.columns)
1819

19-
q = datetime_frame.quantile(0.9, axis=1)
20+
q = df.quantile(0.9, axis=1)
2021
assert (q['2000-01-17'] ==
21-
percentile(datetime_frame.loc['2000-01-17'], 90))
22-
tm.assert_index_equal(q.index, datetime_frame.index)
22+
percentile(df.loc['2000-01-17'], 90))
23+
tm.assert_index_equal(q.index, df.index)
2324

2425
# test degenerate case
2526
q = DataFrame({'x': [], 'y': []}).quantile(0.1, axis=0)
@@ -96,20 +97,8 @@ def test_quantile_axis_parameter(self):
9697
with pytest.raises(ValueError, match=msg):
9798
df.quantile(0.1, axis="column")
9899

99-
def test_quantile_interpolation(self, datetime_frame, int_frame):
100+
def test_quantile_interpolation(self):
100101
# see gh-10174
101-
from numpy import percentile
102-
103-
# interpolation = linear (default case)
104-
q = datetime_frame.quantile(0.1, axis=0, interpolation='linear')
105-
assert q['A'] == percentile(datetime_frame['A'], 10)
106-
q = int_frame.quantile(0.1)
107-
assert q['A'] == percentile(int_frame['A'], 10)
108-
109-
# test with and without interpolation keyword
110-
q1 = int_frame.quantile(0.1)
111-
assert q1['A'] == np.percentile(int_frame['A'], 10)
112-
tm.assert_series_equal(q, q1)
113102

114103
# interpolation method other than default linear
115104
df = DataFrame({"A": [1, 2, 3], "B": [2, 3, 4]}, index=[1, 2, 3])
@@ -154,6 +143,27 @@ def test_quantile_interpolation(self, datetime_frame, int_frame):
154143
index=[.25, .5], columns=['a', 'b', 'c'])
155144
assert_frame_equal(result, expected)
156145

146+
def test_quantile_interpolation_datetime(self, datetime_frame):
147+
# see gh-10174
148+
149+
# interpolation = linear (default case)
150+
df = datetime_frame
151+
q = df.quantile(0.1, axis=0, interpolation='linear')
152+
assert q['A'] == np.percentile(df['A'], 10)
153+
154+
def test_quantile_interpolation_int(self, int_frame):
155+
# see gh-10174
156+
157+
df = int_frame
158+
# interpolation = linear (default case)
159+
q = df.quantile(0.1)
160+
assert q['A'] == np.percentile(df['A'], 10)
161+
162+
# test with and without interpolation keyword
163+
q1 = df.quantile(0.1)
164+
assert q1['A'] == np.percentile(df['A'], 10)
165+
tm.assert_series_equal(q, q1)
166+
157167
def test_quantile_multi(self):
158168
df = DataFrame([[1, 1, 1], [2, 2, 2], [3, 3, 3]],
159169
columns=['a', 'b', 'c'])

0 commit comments

Comments
 (0)