TECHMIND INFOTECH
Computer Education and Project Training Centre
(A Government Approved Institution)
Sri Ram Towers 2nd Floor, Santhanathapuram 6th Street, Pudukkottai
Cell: 7293 52 7293 Email: techmindinfotech020@[Link]
PYTHON PROGRAMMING – CLASS 22
WORKING WITH PANDAS LIBRARY USING PYCHARM
Note:
Install the panda library in Pycharm tool.
Introduction:
Pandas is a Python library.
Pandas is used to analyze data.
CREATING DATA FRAME SET
Example:
import pandas as pd
mydataset = {
'cars': ["BMW", "Volvo", "Ford"],
'passings': [3, 7, 2]
}
myvar = [Link](mydataset)
print(myvar)
Output:
cars passings
0 BMW 3
1 Volvo 7
2 Ford 2
CREATING DATA SERIES
Example:
import pandas as pd
a = [1, 7, 2]
myvar = [Link](a)
print(myvar)
Output:
0 1
1 7
2 2
dtype: int64
CREATING LABLES
Example:
import pandas as pd
a = [1, 7, 2]
myvar = [Link](a, index = ["x", "y", "z"])
print(myvar)
Output:
x 1
y 7
z 2
dtype: int64
Example 2:
import pandas as pd
a = [1, 7, 2]
myvar = [Link](a, index = ["x", "y", "z"])
print(myvar["y"])
Output:
7
;
CREATING SERIES FROM DICITIONARY
Example 1:
import pandas as pd
calories = {"day1": 420, "day2": 380, "day3": 390}
myvar = [Link](calories)
print(myvar)
Output:
day1 420
day2 380
day3 390
dtype: int64
Example 2:
import pandas as pd
calories = {"day1": 420, "day2": 380, "day3": 390}
myvar = [Link](calories, index = ["day1", "day2"])
print(myvar)
Output:
day1 420
day2 380
dtype: int64
Example 3:
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
#load data into a DataFrame object:
df = [Link](data)
print([Link][0])
Output:
calories 420
duration 50
Name: 0, dtype: int64
Example 4:
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = [Link](data, index = ["day1", "day2", "day3"])
print(df)
Output:
calories duration
day1 420 50
day2 380 40
day3 390 45
Example 5:
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = [Link](data, index = ["day1", "day2", "day3"])
print([Link]["day2"])
Output:
calories 380
duration 40
Name: day2, dtype: int64