डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Python module Pandas tutorial

The python library to analyze data.

Install pandas

pip install pandas

import pandas

import pandas as pd

Pandas series

Pandas series are columns
import pandas as pd
x=[1, 2, 3]
s = pd.Series(x)
print(s)
 

Data frames

Pandas uses data set as multi dimensional arrays like tables.
import pandas as pd
x={
"person":['Rama', 'Krishna'],
"age": [20, 30]
}
df = pd.DataFrame(x)
print( df )

Analysis data frames

import pandas as pd 
data={
"day":["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
"wind_speed":[30, 40, 50, 25, 60, 90, 10],
"temprature":[20, 15, 10, 25, 8, 6, 30],
"event":['A', 'B', 'C', 'D', 'E', 'F', 'G']
}
df=pd.DataFrame(data)
print(df)

Shape of data frame

print(df.shape)

Return rows and columns from data frame

rows, cols = df.shape
print(rows)

Fetch top records from data frame

print(df.head())

Fetch only top 2 records from data frame

print(df.head(2))

Fetch bottom top records from data frame

print(df.tail())

Fetch 2 records from bottom 

print(df.tail(2))

Slicing data frame records

print(df[2: 5])

Fetch columns from data frame

print(df.columns)

Fetch single column

print(df.day)

Fetch multiple columns details

print(df[['day', 'event']])

Return maximum value of column 

print(df['temprature'].max())

Return minimum value of column

print(df['temprature'].min())

Return average of column values

print(df['temprature'].mean())

Generate descriptive statistics

print(df.describe())

Fetch all records that has tempratur greater than 10

print(df[df.temprature>10])
© 2016 - 2023, All Rights are Reserved.