본문 바로가기

기초 튼튼/시행착오노트

[시행착오노트] pandas 고유값 카운트: value_counts()

 

 

pandas의 dataframe 사용시, SQL의 count(distinct colName) 문법을 사용하고 싶을 때 사용하는 함수

 

Syntax:

Series.value_counts(normalize=False, sort=True, ascending=False, bins=None, dropna=True)

 

예시:

 

링크:

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.value_counts.html

 

pandas.Series.value_counts — pandas 1.2.4 documentation

Rather than count values, group them into half-open bins, a convenience for pd.cut, only works with numeric data.

pandas.pydata.org

 

https://stackoverflow.com/questions/15411158/pandas-countdistinct-equivalent

 

Pandas count(distinct) equivalent

I am using pandas as a db substitute as I have multiple databases (oracle, mssql, etc) and I am unable to make a sequence of commands to a SQL equivalent. I have a table loaded in a DataFrame with...

stackoverflow.com

 

반응형