Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

change the frequency to column in pandas

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}
Comment

PREVIOUS NEXT
Code Example
Python :: validate ip address python 
Python :: how to convert utf-16 file to utf-8 in python 
Python :: how to import turtle in python 
Python :: how to take input in python3 separated by space 
Python :: beautiful soup get class name 
Python :: python mean ndarray 
Python :: pandas for column in dataframe 
Python :: python code to generate fibonacci series 
Python :: how to round an array in python 
Python :: python convert string to byte array 
Python :: ImportError: /home/user/.local/lib/python3.8/site-packages/pytorch3d/_C.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN2at5zerosEN3c108ArrayRefIlEENS0_13TensorOptionsE 
Python :: How to colour a specific cell in pandas dataframe 
Python :: openpyxl full tutorial 
Python :: how to convert a set to a list in python 
Python :: how to play video in colab 
Python :: how to check if there are duplicates in a list python 
Python :: python key list 
Python :: flask tutorials 
Python :: label encoding in python 
Python :: separate a string in python 
Python :: create dataframe from two variables 
Python :: python regex 
Python :: python send image server 
Python :: python find object with attribute in list 
Python :: how to get today weekday in python 
Python :: How to store password in hashlib in python 
Python :: import argv python 
Python :: what is wsgi 
Python :: del all variables python 
Python :: replace nan numpy array 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =