파이썬(Python)&판다스(Pandas)&Polars

[polars] 특정 조건을 만족하는 데이터 조회(df.filter)

송채채 2023. 11. 21. 16:29

pandas는 df[[df['컬럼'] == 'abc']] 이런 구문으로 찾았는데, polars는 filter라는 함수를 사용함

 

df.filter(pl.col("컬럼") == "abc")

 

  • 조건이 여러개인 경우

공식 홈페이지 예시

df.filter((pl.col("foo") < 3) & (pl.col("ham") == "a"))

 

  • 중복값이 있는 행 조
df.filter(pl.col('컬럼').is_duplicated())
반응형