Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to count number of columns in dataframe python

import pandas as pd
df = pd.DataFrame({"pear": [1,2,3], "apple": [2,3,4], "orange": [3,4,5]})

len(df.columns)
Comment

count elements in columns pandas

df['COL_NAME'].count(axis=1)
Comment

Getting the count of rows and columns in the dataframe

# 2. Shape of a dataframe
df.shape
Comment

PREVIOUS NEXT
Code Example
Python :: django url patterns static 
Python :: get names of all file in a folder using python 
Python :: Upper letter list 
Python :: pygame mixer documentation 
Python :: Python - Change List Items 
Python :: python imaplib send email 
Python :: raise a custom exception python 
Python :: hostname python 
Python :: df to sql mysql 
Python :: ffill python 
Python :: Converting categorical feature in to numerical features 
Python :: increment in python 
Python :: most popular python libraries 
Python :: datetime.time to seconds 
Python :: check if two columns are equal pandas 
Python :: python example 
Python :: python datetime add 
Python :: play sound python 
Python :: how to print a string in python 
Python :: insert column in a dataframe 
Python :: concatenation in python 3 
Python :: torch.stack example 
Python :: python random array 
Python :: python convert two dimensional list to one dimensional 
Python :: python compare objects 
Python :: python empty constructor 
Python :: list deep copy 
Python :: python move and rename files 
Python :: How do I iterate over a subfolder in Python 
Python :: numpy array from list 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =