[Vaex 1.0.0-beta.6] Groupby 사용해보기
2020. 8. 29. 17:45ㆍ분석 Python/Vaex
728x90
group_result = DATA.groupby(["reviewerID"])
group_result.agg("count")
group_result = DATA.groupby(["reviewerID"],agg="count")
아직은 약간 제한이 되는 것 같다
실제로 custom function을 만들려고 하면, 아래쪽과 비슷하게 만들어야 하는데... 어려워 보인다.
일단 주어진 것을 활용해서 해보자.
https://vaex.readthedocs.io/en/latest/_modules/vaex/agg.html#count
vaex.agg — vaex 3.0.0 documentation
© Copyright 2014, Maarten A. Breddels Revision 48531b5d.
vaex.readthedocs.io
여기서 이제 filtering을 하려고 하는데... vaex 자체 내에서 reset_index도 없고, 판다스로 돌리면 시간이 올릴 것 같아서
여러 가지 해봤다.
그래서 찾은 것이 column name을 조회해봤다.
group_result.column_names
group_result.count
###
<bound method DataFrame.count of # reviewerID count
0 A1D4G1SNUZWQOT 1
1 A3DDWDH9PX2YX2 2
2 A2MWC41EW7XL15 1
3 A2UH2QQ275NV45 1
4 A89F3LQADZBS5 1
... ... ...
749,228 AYJ9OR9SOSVL1 1
749,229 A1ZSB2Q144UTEY 1
749,230 A2CCDV0J5VB6F2 1
749,231 A2HO94I89U3LNH 1
749,232 A2RSX9E79DUHRX 1>
count 말고 __count_1라는 것이 있다.
애를 불러보니 다음과 같다.
group_result.__count_1
####
Expression = __count_1
Length: 749,233 dtype: int64 (column)
-------------------------------------
0 1
1 2
2 1
3 1
4 1
...
749228 1
749229 1
749230 1
749231 1
749232 1
이런 식으로 호출된다.
그래서 애를 이용해서 필터링을 하니 가능했다!
group_result[group_result.__count_1 > 10]
하나씩 하나씩 알아가는 재미가...
728x90
'분석 Python > Vaex' 카테고리의 다른 글
[Vaex] Join on Multiple Columns (0) | 2020.09.02 |
---|---|
[Vaex] big data (.csv) covert to hdf5 (0) | 2020.09.02 |
[Vaex 1.0.0-beta.6] Virtual Column 알아보기 (0) | 2020.08.29 |
[Vaex 1.0.0-beta.6] Virtual column 생성 후 pandas로 변경하기 (0) | 2020.08.29 |
[Vaex 1.0.0-beta.6] how to split data from str to list. (0) | 2020.08.29 |