[FEA] support inplace for DataFrame.query
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Is your feature request related to a problem? Please describe.**
using `import cudf as pd`
**Describe the solution you'd like**
```
In [1]: import cudf as pd
In [2]: pd.__version__
Out[2]: '22.12.00'
In [3]: df = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo",
...: "bar", "bar", "bar", "bar"],
...: "B": ["one", "one", "one", "two", "two",
...: "one", "one", "two", "two"],
...: "C": ["small", "large", "large", "small",
...: "small", "large", "small", "small",
...: "large"],
...: "D": [1, 2, 2, 3, 3, 4, 5, 6, 7],
...: "E": [2, 4, 5, 5, 6, 6, 8, 9, 9]})
In [4]: df
Out[4]:
A B C D E
0 foo one small 1 2
1 foo one large 2 4
2 foo one large 2 5
3 foo two small 3 5
4 foo two small 3 6
5 bar one large 4 6
6 bar one small 5 8
7 bar two small 6 9
8 bar two large 7 9
In [5]: df.query("D ** 2 > 8")
Out[5]:
A B C D E
3 foo two small 3 5
4 foo two small 3 6
5 bar one large 4 6
6 bar one small 5 8
7 bar two small 6 9
8 bar two large 7 9
In [6]: df.query("D ** 2 > 8", inplace=True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 df.query("D ** 2 > 8", inplace=True)
TypeError: query() got an unexpected keyword argument 'inplace'
In [7]: pdf = df.to_pandas()
In [8]: pdf
Out[8]:
A B C D E
0 foo one small 1 2
1 foo one large 2 4
2 foo one large 2 5
3 foo two small 3 5
4 foo two small 3 6
5 bar one large 4 6
6 bar one small 5 8
7 bar two small 6 9
8 bar two large 7 9
In [9]: pdf.query("D ** 2 > 8", inplace=True)
In [10]: pdf
Out[10]:
A B C D E
3 foo two small 3 5
4 foo two small 3 6
5 bar one large 4 6
6 bar one small 5 8
7 bar two small 6 9
8 bar two large 7 9
```
Contributor guide
Assessment
This issue has not been assessed yet.