DEV Community

GharamElhendy
GharamElhendy

Posted on

Exploring Data with Pandas

import pandas as pd
df = pd.read_csv('name_of_file.csv')

to display the no of rows and columns, respectively

df.shape

alternative method

print("This data set has {} rows and {} columns".format(df.shape[0], df.shape[1]))

to display first 5 rows

df.head()

to display the data types of each column as well as the number of cells with values (helps to find missing values in each column)

df.info()

alternative method

dataTypeSeries = df.dtypes
print('Data type of each column of Dataframe :')
print(dataTypeSeries)

to check null values

df.isnull()
df.notnull()

to check how may unique values in each column

df.nunique()

a specific column's would be:

df.column_name.nunique()

to check the count, mean, st deviation, min, 25%, 50%, 75%, and max of each of the columns in the data set

df.describe()

Latest comments (2)

Collapse
 
arvindpdmn profile image
Arvind Padmanabhan

The next step for a beginner to learn Pandas is to get familiar with DataFrame and its operations. This may help: devopedia.org/pandas-dataframe-ope...

Collapse
 
gharamelhendy profile image
GharamElhendy

Absolutely grateful for this, thank you Arvind. :)