[pandas] 0이 포함된 로우 선택
2021. 12. 13. 17:15ㆍMachine Learning
# 0이 하나라도 포함된 로우
df[(df == 0)].any(axis=1)
# 단 하나의 0도 포함하지 않은 로우
df[(df !=0)].all(axis=1)
Drop row in pandas dataframe if any value in the row equals zero
How do I drop a row if any of the values in the row equal zero? I would normally use df.dropna() for NaN values but not sure how to do it with "0" values.
stackoverflow.com
반응형
'Machine Learning' 카테고리의 다른 글
[pandas] 특정 컬럼을 Datetime 형으로 (0) | 2021.11.25 |
---|---|
[pandas] DataFrame의 0을 NaN으로 변경하는 방법 (0) | 2018.03.29 |
[pandas] timestamp를 datetime으로 (0) | 2018.03.29 |
[pandas] 다른 컬럼의 값을 인덱스로 설정하는 방법 (0) | 2018.03.29 |