Learning Pandas

 

Let's learn Pandas

Pandas is a like a our excel sheet we make the arrangement of the items in a such a way that 
it looks like a excel sheet and it is very useful in making the data analysis 
primary use of the Pandas is for the data analysis

It usage the power and the speed of the numpy to make data analyis
Pandas has two type of the data sets
seies-It is one dimentional array with indexes,it stores a single column
or row of data in a DataFrame

import pandas as pd
import numpy as np
Pandas  has a two types of the data sets one is series and other is Dataframe
se=pd.Series()
print(se)
lis=np.array(["M","a","j","ad"])
ser=pd.Series(lis)
print(ser)
pandas series is nothing but creating the column by using the array
arr=np.array([1,2,3,4,5])
ser=pd.Series(arr,index=["one","two","three","fours","five","six"])
print(ser)
note that we have to insert same number of the index as elements present inthe array
output
one 1
two 2
three 3
fours 4
five 5
dtype: int32
list_1=[1,2,3,4,5]
ser=pd.Series(list_1)
print(ser)
output
0 1
1 2
2 3
3 4
4 5
dtype: int64
dic_1={1:"kolhapur",2:"Solapur",3:"Satara",4:'Pune',5:"Mumbai"}
ser=pd.Series(dic_1)
print(ser)
we can also use the dictionary for the series
1 kolhapur
2 Solapur
3 Satara
4 Pune
5 Mumbai
dtype: object
ser = pd.Series(10, index=[0, 1, 2, 3, 4, 5])
print(ser)
0 10
1 10
2 10
3 10
4 10
5 10
dtype: int64
The linspace divide the numbers in the AP(arithmetic progression)
print(np.linspace(1,33,33))
ser=pd.Series(np.linspace(1,4,5))
print(ser)
output contains the column as 5 elements in between the 1 and 4 in
a such way that they are in the arithmetic progreestion
0 1.00
1 1.75
2 2.50
3 3.25
4 4.00
In case of the python data frame three main components are there
Rows ,columns and data
df=pd.DataFrame()
#print(df)
list_1=[1,2,3,4,5]
df=pd.DataFrame(list_1)
print(df)

arr={"Name":["Manja","Ganja","Tabaki","me"],"Food":[2,3,4,5]}
df=pd.DataFrame(arr)
#print(df[["Name"]])
for i,j in df.iterrows():
print(i,j)
print()
data=pd.read_excel("dff.excel",index_col="Branch")
print(data)
d={"Item":["Table","Chair","Dining"],"Price":[1000,500,20000]}
df=pd.DataFrame(d)
print(df)
df.to_csv("friends.csv",index=False)
it is used for the removal of the index
print(df.describe())
Price
count 3.000000
mean 7166.666667
std 11116.804097
min 500.000000
25% 750.000000
50% 1000.000000
75% 10500.000000
max 20000.000000
By using the index method we can associate the any value to the first column
df.index=[1,2,3]
print(df)
like pandas==excel
It usage the power and the speed of the numpy to make data analyis
Pandas has two type of the data sets
seies-It is one dimentional array with indexes,it stores a single column
or row of data in a DataFrame
Dataframe-its tabular
ser=pd.Series(np.random.rand(10))
ser.index=[1,2,3,4,5,6,7,8,9,10]
print(ser)
dff=pd.DataFrame(np.random.rand(301,3),index=np.arange(301))
print(type(dff))
print(dff.describe())
dff[0][0]="Manja"
dff.loc[0,0]=98
dff.columns=list("ABC")
print(dff.head())
df=pd.DataFrame(np.array(["Manja","Ganja"]))
df.columns=list("MOHAN")
df.index=list("GANJA")
print(df.describe())
print(df.max(axis=1))
print(df)
for more information about the python

Post a Comment

Previous Post Next Post