-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Needs InfoClarification about behavior needed to assess issueClarification about behavior needed to assess issue
Description
Sample data for replication:
data = pd.DataFrame({'a': list(range(100)),
'b': list(range(100))})
This works:
pd.qcut(data['a'], 3)
But this does not work:
def test(data, col, cuts=3):
return pd.qcut(data[col], cuts)
test(data, 'a', 3)
Pandas version: '0.24.1'
Problem description
When I wrap a pandas pd.qcut() inside a function, I get an error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-17-c8b08c24ec5c> in <module>
8
9
---> 10 test(first, 'BUN', 3)
11
12 #pd.qcut(first['BUN'], 3)
<ipython-input-17-c8b08c24ec5c> in test(data, col, cuts)
5 col = []
6
----> 7 return pd.qcut(data[col], cuts)
8
9
~/miniconda3/envs/wip_conda/lib/python3.6/site-packages/pandas/core/reshape/tile.py in qcut(x, q, labels, retbins, precision, duplicates)
300 array([0, 0, 1, 2, 3])
301 """
--> 302 x_is_series, series_index, name, x = _preprocess_for_cut(x)
303
304 x, dtype = _coerce_to_type(x)
~/miniconda3/envs/wip_conda/lib/python3.6/site-packages/pandas/core/reshape/tile.py in _preprocess_for_cut(x)
512 x = np.asarray(x)
513 if x.ndim != 1:
--> 514 raise ValueError("Input array must be 1 dimensional")
515
516 return x_is_series, series_index, name, x
ValueError: Input array must be 1 dimensional
Metadata
Metadata
Assignees
Labels
Needs InfoClarification about behavior needed to assess issueClarification about behavior needed to assess issue