New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Series.pop #789
Comments
@HyukjinKwon Oh it looks interesting. i'll try this out :) |
https://github.com/pandas-dev/pandas/blob/v0.25.1/pandas/core/generic.py#L821-L869 |
Yes i checked that too but from my cursory look, we cannot share implementation in Koalas. In this case, it might better to have two separate APIs with two separate examples. It's fine to have some differences if that looks obviously better. |
i'm working on this. |
Resolves #789 ```python >>> s = ks.Series(data=np.arange(3), index=['A', 'B', 'C']) >>> s A 0 B 1 C 2 Name: 0, dtype: int64 >>> s.pop('A') A 0 Name: 0, dtype: int64 >>> s B 1 C 2 Name: 0, dtype: int64 ``` Also support for MultiIndex ```python >>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'], ... ['speed', 'weight', 'length']], ... [[0, 0, 0, 1, 1, 1, 2, 2, 2], ... [0, 1, 2, 0, 1, 2, 0, 1, 2]]) >>> s = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], ... index=midx) >>> s lama speed 45.0 weight 200.0 length 1.2 cow speed 30.0 weight 250.0 length 1.5 falcon speed 320.0 weight 1.0 length 0.3 Name: 0, dtype: float64 >>> s.pop('lama') lama speed 45.0 weight 200.0 length 1.2 Name: 0, dtype: float64 >>> s cow speed 30.0 weight 250.0 length 1.5 falcon speed 320.0 weight 1.0 length 0.3 Name: 0, dtype: float64 ``` And beyond pandas, we can support for MultiIndex with specifying level. (But i'm not sure this is necessary.) ```python >>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'], ... ['speed', 'weight', 'length']], ... [[0, 0, 0, 1, 1, 1, 2, 2, 2], ... [0, 1, 2, 0, 1, 2, 0, 1, 2]]) >>> s = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], ... index=midx) >>> s lama speed 45.0 weight 200.0 length 1.2 cow speed 30.0 weight 250.0 length 1.5 falcon speed 320.0 weight 1.0 length 0.3 Name: 0, dtype: float64 >>> s.pop('speed', level=1) lama speed 45.0 cow speed 30.0 falcon speed 320.0 Name: 0, dtype: float64 >>> s lama weight 200.0 length 1.2 cow weight 250.0 length 1.5 falcon weight 1.0 length 0.3 Name: 0, dtype: float64 ``` In pandas, above example raises TypeError like below: ```python Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: pop() got an unexpected keyword argument 'level' ```
filter out given arugmnet in the series. See https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.pop.html?highlight=pop#pandas.Series.pop
Related to #362
The text was updated successfully, but these errors were encountered: