Unit 1 Python programming II
Work done till yet to be completed in your AI copy
CW- SrNo 1.1
Date-11/03/26
What is numpy and it's use
Difference between list and numpy
Example of numpy-
Creating 1D array
Creating 2D array
l1=[1,2,3]
l2=[4,5,6]
print(l1+l2)
import numpy as np
a1=[Link]([1,2,3])#Ex of 1D Array
a2=[Link]([4,5,6])
print(a1+a2)
print(a1[1])
print(a2[-2])
a3=[Link](([11,22,33],[44,55,66]))
print(a3)
print(a3[:1,1:],"\n", a3[1:,1:])
SrNo 1.2 Application on numpy in AI
Date-12/3/26
CF-why do we use Pandas Library
Data structures in Pandas-Series and dataframe
Example of series
import pandas as pd
s = [Link]([10,20,30,40])
print(s)
Example of Creating DataFrame using Numpy arrays
import pandas as pd
import numpy as np
data1=[Link]([22,33,44])
data2=[Link]([52,63,64])
data3=[Link]([12,53,74])
df=[Link]([data1,data2,data3],columns=["A","B","C"])
print(df)
Date- 13/3
CF
SrNo. 1.3 Creating dataframe using dictionary example
import pandas as pd
data={
"student":["Riya","Rohit","Aditya","Neha"],
"Maths":[67,78,89,78],
"Science":[67,88,77,99],
"English":[77,89,89,98]
}
df=[Link](data)
[Link][4]=["Aarav",78,87,68]
[Link][2]=["Aditya",98,78,90]
df["City"]=["Delhi","Noida","Gzb,","Delhi","Gzb"]
print(df)
df=[Link](0)
print(df)
df=[Link](["City","English"],axis=1)
print(df)
Features used in the above coding
-Creating a student table using dictionary as DataFrame
-Displaying DataFrame
-Adding of new row
-Updating of existing row
-Dropping a row
-Dropping column/multiple columns
CF
[Link] 1.4 – Date 02/04/26
Sub topic- Import and Export Data between CSV Files and DataFrames
Steps
Create a Excel File with the given data and save file with csv format
Open python fiddle and upload the excel file
Write the python code to export the data
import pandas as pd
df=pd.read_csv("[Link]")
print(df)
Sub topic- Handling Missing Values
i) Drop the row having missing values OR
ii) Estimate the missing value
Checking Missing Values – isNull()
Drop Missing Values-dropna()
Estimate the missing value- fillna(0)/fillna(1)
[Link] 1.5 (Home Fun) Date- 09/04/26
A. Short Answer Questions
1. What is a DataFrame in Pandas?
2. How do you create a Pandas Series from a dictionary?
3. Name two strategies to handle missing values in a DataFrame.
4. What does the head(n) function do in a DataFrame?
5. What is the role of NumPy in Python programming?
6. Explain the use of the isnull() function in Pandas.
B. Long Answer Questions
1. Describe the steps to import and export data using Pandas.
2. Explain the concept of handling missing values in a DataFrame with examples.
3. Compare NumPy arrays and Pandas DataFrames.
4. How can we add new rows and columns to an existing DataFrame? Explain with code
examples.
5. What are the attributes of a DataFrame? Provide examples.