You can use value_counts
and to_dict
:
print df['status'].value_counts()
N 14
S 4
C 2
Name: status, dtype: int64
counts = df['status'].value_counts().to_dict()
print counts
{'S': 4, 'C': 2, 'N': 14}
More Related Contents:
- How to split a dataframe string column into two columns?
- How to drop rows of Pandas DataFrame whose value in a certain column is NaN
- Annotate bars with values on Pandas bar plots
- Comparing two dataframes and getting the differences [duplicate]
- How to make separator in pandas read_csv more flexible wrt whitespace, for irregular separators?
- Why isn’t my Pandas ‘apply’ function referencing multiple columns working? [closed]
- Convert the string 2.90K to 2900 or 5.2M to 5200000 in pandas dataframe
- Conditionally fill column values based on another columns value in pandas
- Get the name of a pandas DataFrame
- pandas concat generates nan values
- Remove duplicate rows from Pandas dataframe where only some columns have the same value
- Normalize columns of a dataframe
- How to replace negative numbers in Pandas Data Frame by zero
- Python Pandas Group by date using datetime data
- Removing the timestamp from a datetime in pandas dataframe
- Convert pandas data frame to series
- vectorize conditional assignment in pandas dataframe
- Pandas DataFrame merge summing column
- Mapping ranges of values in pandas dataframe [duplicate]
- Binning a column with pandas
- How can I replicate rows of a Pandas DataFrame?
- Convert month int to month name in Pandas
- How to get/set a pandas index column title or name?
- Python pandas integer YYYYMMDD to datetime
- Pandas: drop columns with all NaN’s
- In Python pandas, start row index from 1 instead of zero without creating additional column
- Python: How to drop a row whose particular column is empty/NaN?
- How to upload a CSV file in FastAPI and convert it into a Pandas Dataframe?
- DataFrame object has no attribute append
- Python Pandas : pandas.to_datetime() is switching day & month when day is less than 13