Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

value_count pandas change column name

df = df.value_counts().rename_axis('unique_values').reset_index(name='counts')
print (df)
   unique_values  counts
0              2       3
1              1       2
Comment

PREVIOUS NEXT
Code Example
Python :: how to print to a file in python 
Python :: matplotlib draw two histograms on same image 
Python :: python find index of minimum in list 
Python :: pytorch detach 
Python :: Write a python program to find the most frequent word in text file 
Python :: python regex cheat sheet 
Python :: python pd.DataFrame.from_records remove header 
Python :: merge two df 
Python :: start virtualenv 
Python :: palindrome rearranging python 
Python :: Delete file in python Using the pathlib module 
Python :: python getter decorator 
Python :: python get input from console 
Python :: create 3x3 numpy array 
Python :: how to commenbt code in python 
Python :: pandas subtract days from date 
Python :: Adding new column to existing DataFrame in Pandas by assigning a list 
Python :: find by class bs4 
Python :: circular array python 
Python :: how to read text frome another file pythion 
Python :: getting the file path of a file object in python 
Python :: numpy matrix 
Python :: django and operator 
Python :: python find number of occurrences in list 
Python :: pd count how many item occurs in another column 
Python :: 2 variables with statement python 
Python :: python make file path os 
Python :: drop column with nan values 
Python :: python dictonary of dictonary 
Python :: set size of button tkinter 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =