Pragya File
Pragya File
Pragya File
List Of Programs:
1.Write code to create a series object using the python
sequence (4,6,8,10).Assume that Pandas is imported as
alias name pd.
Solution2:-
1.import pandas as pd
2.import numpy as np
3.L1=[11,21,31,41]
4.S1=pd.Series(L1)
5.Print(S1)
Output:
Solution3:
Import pandas as pd
Import numpy as np
Cls12={“A”:10,”B”:20,”C”:30}
S1=pd.Series(Cls12)
Print(S1)
Output:
Solution4:
Import pandas as pd
Import numpy as np
Year={“Qtr1”:50000,”Qtr2”:50000,”Qtr3”:50000,”Qtr4”:500000}
S1=pd.Series(Year)
Print(S1)
Output:
Solution5:
Import pandas as pd
Import numpy as np
S1=Pd.Series(S13)
Print(S13={“A”:6700,”B”:5600,”C”:5000,”D”:5200}
s1)
Output:
Solution6:
Import pandas as pd
Import numpy as np
Data=[1,2,3,4,5,6,7,8,9,1o]
S1=pd.Series(data)
#for first three rows
First_three=s1.head(3)
Print(first_three)
Output:
Solution7:
Import pandas as pd
Dict1={‘Section’:[‘A’,’B’,’C’,’D’],”contri”:[16700,5600,5000,5200]}
Df1=pd.DataFrame(Dict1)
Print(Df1)
Output:
Solution8:
Import pandas as pd
define the 2D list
data=[[101,113,124],[130,140,200],[115,216,217]]
df=pd.DataFrame(data,columns=[“columns1”,”column2”,”column
3”])
print(df)
Output:
Solution9:
Import pandas as pd
Data=[[58,20,”Chetan”],[55,17,”Aditya”],[60,20,”Prachi”]]
Index=[‘A’,’B’,’C’]
df=pd.DataFrame(data,index=index,columns=[”Weight”,”Age”,”Na
mes”])
print(df)
Output:
Solution10:
import pandas as pd
data=[[101,113,124],[130,140,200],[115,216,217]]
df=pd.DataFrame(data,columns=[‘Column1’,’Column2’,’Column3’
])
print(df)
#Output:
Solution11:
Import pandas as pd
Import numpy as np
Arr1=np.array([[11,12],[13,14],[15,16]].np.int32)
Dtf2=pd.DataFrame(Arr1)
Print(Dtf2)
Output:
Solution12:
Import pandas as pd
Data=[[7916,6189,610],[8508,8208,508]]
Index=[“Andhra”,”Odisha”]
Aid=pd.DataFrame(Data,Index=Index,Columns=[“Toys”,”Books”,”U
niform”])
Print(aid)
Output:
Solution13:
Import pandas as pd
Data=[[6189,610],[8208,508]]
Index=[“Andhra”,”Odisha”]
#to print Books and Uniform data
df_books_uniform=aid[[“Books”,”Uniform”]]
print(df_books_uniform)
#output:
Solution14:
Import pandas as pd
df_uniform=aid[[“Uniform”]]
print(df_uniform)
Output:
Solution15:
Import pandas as pd
data= [[7916,6189,610],[8508,8208,508]]
index=[“Andhra”,”Odisha”]
aid=pd.DataFrame(data,index=index,
columns=[“Toys”,”Books”,”Uniform”])
print(aid)
df1[“Laptops”]=[300,400]
print(df1)
Output:
Solution16:
Import pandas as pd
d1=[[56000,58000],[70000,68000],[75000,78000]]
index=[“ZoneA”,”ZoneB”,”ZoneC”]
df1=pd.DataFrame(d1,index=index,columns=[“Target”,”Sales”)
Output:
Solution17:
Import pandas as pd
df1=df1.rename
(index={“zoneB”:”Central”,”zoneC”:”Dakshin”})
df1=df1.rename(columns={“Sales”:”Achieved”})
print(df1)
#Output:
Solution18:
Import pandas as pd
Df1[“Targeted”]=[60000,75000,76000]
Df1[“Achieved”]=[56000,69000,79000]
Print(Df1)
#Output:
Solution19:
Zone_c_data=df1.loc[“zoneC”]
Print(Zone_c_data)
#Output:
Solution20:
Import pandas as pd
Data={‘Name’:[‘Alice’,’Bob’,’Charlie’,’David’,’Eve’],
‘Age’:[25,32,18,47,31], ‘Gender’:[‘Female’,’Male’,’Male’,
‘Male’,’Female’]}
df= pd.DataFrame(Data)
bi1=df[‘Age’] >30
bi2=df[‘Gender’]==’Female’
filtered_df=df(bi1 &bi2)
print(filtered_df)
Output:
Questions Of Matplotlib:
By Using Matplotlib:
1. DPS school celebrated volunteering week where each section of class
11 dedicated a day for collecting amount for charity being supported by
the school. Section A volunteered on Monday, B on Tuesday, C on
Wednesday and so on. There are six section in class 11. Amounts collected
by section A to F are 8000,12000,9800,11200,15500,7300. Draw a bar
chart to show the collection of amounts graphically.
2. A survey gather height and weight of 100 participants and recorded the
participant’s ages:-
Ages=[1,1,2,3,5,7,8,9,10,10,11,13,13,15,16,17,18,19,20,21,21,23,24,24,24,2
5,25,25,25,26,26,26,27,27,27,27,27,29,30,30,30,30,31,33,34,34,34,35,36,3
6,37,37,37,38,38,39,40,40,41,41,42,43,45,45,46,46,46,47,48,48,49,50,51,5
1,52,52,53,54,55,56,57,58,60,61,63,65,66,68,70,72,74,75,77,81,82,84,87,8
9,90,91].Write a program to plot a histogram from above data with 20
bins.
3. Consider a DataFrame mksdf as shown below:Name Age
PreBoardMarks BoardMarks 0 Karan 17 4 25 1 Alex 19 24 94 2 Ani 18 31
57 3 Javed 18 2 62 4 Amrit 17 3 70. Write a program to plot pre-board-
marks and board marks from above DataFrame on the same line chart.
4. Mr.Sharma is working a game development industry and he was
comparing the given chart on the basis of the rating of the various games
Available on the play store. Write the code to draw the given bar graph.
Answers
Solution1:
Output:
Solution2:
Output:
Solution3:
Output:
Solution4:
Output:
My Sql Queries:
1.Write a Sql command to create a DataBase
named ‘School’.
2.Create a student table with the student id, name,
and marks as attributes where the student id is
primary key.
3.Add columns ‘Mobile’ and ‘Sex’ in the table
student.
4.Add column’Address’ in the table student.
5.Change the name of column ‘Sex’ to ‘Gender’.
6.Delete a column ‘Address’ from table Student.
7.Insert the details of 10 new students in the above
table.
8.Use the select command to get the details of the
students with marks more than 80.
9.Change the mobile number of any one student.
10.Display the details of those students which name
start with’A’.
11.Write output:Select
Length(Name),Substr(Name,3,3) From Student;
12.Write output:Select Count(DistrictGender) From
Student;
13.Display a report like’Aditya’ is scored 20 out 30’
for each student. Where aditya is the name of
student and 20 is the marks of aditya.
14.Find the min,max and average of the marks in a
student marks table.
15.Display the Gender,Minimum marks and
Maximum marks Gender wise.
16.Find the total number of students from student
table gender by using group by.5 Python MySql.
17.Write a Sql query to order the(student Id,marks)
table in descending order.
18.Delete the details of a student in the above table.
19.Delete the table Student.
20.Delete the DataBase School.
Solution of My Sql:
Solution1:
Solution2:
Solution3:
Solution4:
Solution5:
Solution6:
Solution7:
Solution8:
Solution9:
Solution10:
Solution11:
Solution12:
Solution13
Solution14:
Solution15:
Solution16:
Solution17:
Solution18:
Solution19:
Section20: