Series Report
Series Report
Series Report
Import pandas as pd
D = {"karamjeet": 17, "Mandeep":
17, "TAMAN": 17}
s = pd.Series(D)
print(s[s > 75])
OUTPUT:-
import pandas as pd
Budget = pd.Series(40000,
index={'qtr1', 'qtr2', 'qtr3', 'qtr4'})
print(Budget)
Output:-
qtr2 40000
qtr4 40000
qtr1 40000
qtr3 40000
dtype: int64
#write a Python program to create a
Series object that stores the
Employee names as index and their
Salary as values.(SERIES USING
NUMPY ARRAY )
import pandas as pd
import numpy as np
section = ['A', 'B', 'C']
contribution = np.array([1200, 1400,
np.nan])
s = pd.Series(data=contribution,
index=section)
print(s)
Output:-
A 1200.0
B 1400.0
C NaN
dtype: float64
#Write a Python program to create a Series object
with Employee names as the index and their
salaries as values. Accept the name of the employee
whose salary needs to be changed, along with the
new salary, and update it in the Series . (PYTHON
PROGRAM FOR MODIFYING OR UPDATING
EXISTING VALUES OF SERIES OBJECT).
import pandas as pd
D = {'RANA': 50000, 'RAMA': 40000, 'AMAN': 34000,
'ASHISH': 53000}
S = pd.Series(D)
print("Employees salary before updating")
print(S)
print("")
opt = input("Do you want to update the salary of the
employee (y/n)?: ")
if opt.lower() == 'y':
name = input("Enter the name of employee: ")
if name in S.index:
new_salary = float(input("Enter the new salary: "))
S[name] = new_salary
print("Salary updated successfully:")
print("Employees salary after updating")
print(S)
else:
print("Employee not found in record.")
else:
print("Thank You!!!")
Output:-
Employees salary before updating
RANA 50000
RAMA 40000
AMAN 34000
ASHISH 53000
dtype: int64
OUTPUT:-
The addition of two series object is :
a 12.0
b 25.0
c NaN
d NaN
e NaN
f NaN
dtype: float64
The Subtraction of two series object is:
a 8.0
b 15.0
c NaN
d NaN
e NaN
f NaN
dtype: float64
the multiplication of two series object is :
a 20.0
b 100.0
c NaN
d NaN
e NaN
f NaN
dtype: float64
the division of two series object is:
a 5.0
b 4.0
c NaN
d NaN
e NaN
f NaN
dtype: float64
OUTPUT:-
The index of the series is: Index(['a', 'b', 'c', 'd', 'e'],
dtype='object')
The datatype of the series is: int64
The size of the series is: 5
The shape of the series is: (5,)
The NaN of the series is: False
OUTPUT:-
stud1 10
stud2 20
stud3 30
stud4 40
stud5 50
dtype: int64
2. DATAFRAME
● DATFRAME CREATION
USING DIFFERENT METHOD
●DATAFRAME ATTRIBUTES
●DATAFRAME AND CSV
●OPERATION ON DATAFRAME