We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9dc4d71 commit 30a42c1Copy full SHA for 30a42c1
pandas/core/groupby/groupby.py
@@ -1947,8 +1947,8 @@ def post_processor(vals: np.ndarray, inference: Optional[Type]) -> np.ndarray:
1947
arrays = []
1948
1949
for i in range(self.ngroups):
1950
- arr = arr + i
1951
- arrays.append(arr)
+ arr2 = arr + i
+ arrays.append(arr2)
1952
1953
indices = np.concatenate(arrays)
1954
assert len(indices) == len(result)
pandas/tests/groupby/test_function.py
@@ -1257,6 +1257,24 @@ def test_quantile_array():
1257
tm.assert_frame_equal(result, expected)
1258
1259
1260
+def test_quantile_array2():
1261
+ # https://github.com/pandas-dev/pandas/pull/28085#issuecomment-524066959
1262
+ df = pd.DataFrame(
1263
+ np.random.RandomState(0).randint(0, 5, size=(10, 3)), columns=list("ABC")
1264
+ )
1265
+ result = df.groupby("A").quantile([0.3, 0.7])
1266
+ expected = pd.DataFrame(
1267
+ {
1268
+ "B": [0.9, 2.1, 2.2, 3.4, 1.6, 2.4, 2.3, 2.7, 0.0, 0.0],
1269
+ "C": [1.2, 2.8, 1.8, 3.0, 0.0, 0.0, 1.9, 3.1, 3.0, 3.0],
1270
+ },
1271
+ index=pd.MultiIndex.from_product(
1272
+ [[0, 1, 2, 3, 4], [0.3, 0.7]], names=["A", None]
1273
+ ),
1274
1275
+ tm.assert_frame_equal(result, expected)
1276
+
1277
1278
def test_quantile_array_no_sort():
1279
df = pd.DataFrame({"A": [0, 1, 2], "B": [3, 4, 5]})
1280
result = df.groupby([1, 0, 1], sort=False).quantile([0.25, 0.5, 0.75])
0 commit comments