0% found this document useful (0 votes)
2 views7 pages

AES 12th IP All QA With Code0000000000000

The document contains various code snippets demonstrating the creation and manipulation of Pandas Series and DataFrames in Python. It includes examples of generating even numbers, handling empty Series, filtering DataFrames based on conditions, and modifying DataFrame columns. Additionally, it showcases how to create DataFrames with specific structures and data types.

Uploaded by

parthpawarr366
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

AES 12th IP All QA With Code0000000000000

The document contains various code snippets demonstrating the creation and manipulation of Pandas Series and DataFrames in Python. It includes examples of generating even numbers, handling empty Series, filtering DataFrames based on conditions, and modifying DataFrame columns. Additionally, it showcases how to create DataFrames with specific structures and data types.

Uploaded by

parthpawarr366
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Q1

Code:
even_series = pd.Series([2 * i for i in range(1, 11)])
Output:
0 2
1 4
2 6
3 8
4 10
5 12
6 14
7 16
8 18
9 20

Q1 (i)
Code:
even_series.head(4)
Output:
0 2
1 4
2 6
3 8

Q1 (ii)
Code:
even_series.empty
Output:
False

Q1 (iii)
Code:
even_series.sort_values()
Output:
0 2
1 4
2 6
3 8
4 10
5 12
6 14
7 16
8 18
9 20

Q1 (iv)
Code:
even_series[even_series > 6]
Output:
3 8
4 10
5 12
6 14
7 16
8 18
9 20

Q2
Code:
pd.Series(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
"Sunday"])
Output:
0 Monday
1 Tuesday
2 Wednesday
3 Thursday
4 Friday
5 Saturday
6 Sunday

Q3
Code:
pd.Series(dtype='float64')
Output:
Series([], )

Q4
Code:
pd.Series(["Taj Mahal", "Qutub Minar", "Charminar", "Gateway of India"],
index=["Uttar Pradesh", "Delhi", "Telangana", "Maharashtra"])
Output:
Uttar Pradesh Taj Mahal
Delhi Qutub Minar
Telangana Charminar
Maharashtra Gateway of India

Q5
Code:
pd.Series([75, 78, 82, 86], index=["ENGLISH", "HINDI", "MATHS", "SCIENCE"])
Output:
ENGLISH 75
HINDI 78
MATHS 82
SCIENCE 86
Q5 Count
Code:
marks_series.count()
Output:
4

Q6
Code:
pd.Series({'a': 0., 'b': 1., 'c': 2})
Output:
a 0.0
b 1.0
c 2.0

Q7
Code:
pd.Series([5]*4)
Output:
0 5
1 5
2 5
3 5

DF Q1
Code:
pd.DataFrame({"Empid": [...], "Ename": [...], "DOJ": [...]})
Output:
Empid Ename DOJ
0 201 Ankit 2021-06-01
1 202 Bhavna 2020-09-15
2 203 Chetan 2019-12-20
3 204 Divya 2022-04-10
4 205 Ekta 2023-01-25

DF Q2
Code:
pd.DataFrame({"player": [...], "Team": [...], "Cetegory": [...], "BidPrize": [...],
"Runs": [...]})
Output:
player Team Cetegory BidPrize Runs
0 Hardik Mumbai Indians Batsman 13 1000
1 Rahul Kings eleven Batsman 12 2400
2 Virat RCB Batsman 17 3600
3 Rohit Mumbai Indians Batsman 15 3700
4 Jasprit Mumbai Indians Bowler 10 200

DF Q3 (i)
Code:
df3[["Name", "ID", "Dept", "Salary"]]
Output:
Name ID Dept Salary
0 Amit 1 HR 13000
1 Bina 2 IT 11000
2 Chirag 3 Finance 15000
3 Deepa 4 IT 9000
4 Esha 5 HR 12500

DF Q3 (ii)
Code:
df3[df3["Salary"] > 12000]
Output:
ID Name Salary Dept
0 1 Amit 13000 HR
2 3 Chirag 15000 Finance
4 5 Esha 12500 HR

DF Q4
Code:
pd.DataFrame({...}, index=["C1", "C2", "C3", "C4", "C5"])
Output:
City MaxTemp MinTemp Rainfall_mm
C1 Delhi 42 26 12
C2 Mumbai 38 29 45
C3 Chennai 36 28 50
C4 Kolkata 40 27 20
C5 Jaipur 41 25 10

DF Q5
Code:
pd.DataFrame({"enrolmentNo": [...], "Name": [...], ...})
Output:
enrolmentNo Name class section project_name
0 101 Aman XII A AI
1 102 Beena XII B ML
2 103 Chetan XII A CV

DF Q5 (i)
Code:
df5[["Name", "section"]]
Output:
Name section
0 Aman A
1 Beena B
2 Chetan A
DF Q5 (ii)
Code:
df5[df5["enrolmentNo"].isin([101, 103])]
Output:
enrolmentNo Name class section project_name
0 101 Aman XII A AI
2 103 Chetan XII A CV

DF Q6
Code:
pd.DataFrame({"company_name": [...], "price": [...], "vehicle_horsepower": [...]})
Output:
company_name price vehicle_horsepower
0 Honda 800000 98
1 Hyundai 750000 85
2 Toyota 900000 105

DF Q7
Code:
pd.DataFrame()
Output:
Empty DataFrame
Columns: []
Index: []

DF Q8
Code:
pd.DataFrame(["red", "green", "blue", "yellow"], columns=["Colors"])
Output:
Colors
0 red
1 green
2 blue
3 yellow

DF Q9
Code:
pd.DataFrame(Dic)
Output:
roll name marks
0 1 A 87
1 2 B 92
2 3 C 78

DF Q10
Code:
pd.DataFrame(S, columns=["Numbers"])
Output:
Numbers
0 1
1 2
2 3
3 4

DF Q11
Code:
pd.DataFrame(L11, columns=["Marks"])
Output:
Marks
0 29
1 42
2 55
3 22
4 84
5 56

DF Q12
Code:
EMP["Salary"] = EMP["Basic"] + EMP["Da"] + EMP["Hra"]
Output:
Names Basic Da Hra Salary
0 Sanya 9500 3000 2000 14500
1 Krish 7000 5000 1900 13900
2 Rishav 9650 1500 2100 13250
3 Deepak 7500 2000 2700 12200
4 Kriti 9200 1800 500 11500

DF Q12 (Columns)
Code:
EMP.columns.tolist()
Output:
['Names', 'Basic', 'Da', 'Hra', 'Salary']

DF Q12 (Column Count)


Code:
EMP.shape[1]
Output:
5

DF Q13
Code:
df13.insert(1, "age", [18, 19, 18])
Output:
roll age name marks
0 1 18 a 24
1 2 19 b 53
2 3 18 c 66

DF Q14
Code:
df14.columns = ["A", "B"]
Output:
A B
0 1 4
1 2 5
2 3 6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy