Pandas & Mysql
Pandas & Mysql
2. The series I a one dimensional labeled array capable of holding data on any type.
3. The series data is mutable. But the size of series data is immutable.
4. Numpy is a python package which stands for numeric python.
5. Dataframe is 2 dimensional array with heterogeneous data usually represented in tabular format.
6. Dataframe has two different index- column index and row index.
7. import pandas as pd
s=pd.Series([5,10,15,20,25])
--> As you know that series object is autometically indexed as 0,1,2,3,4. Write a python code to assign a series as
a,b,c,d,e
Ans. s.index=['a','b','c','d','e']
f. gr.drop(‘grade’,axis=1)
g. gr.drop([2,4])
h. a. first row from the dataframe gr will be deleted.
b. first row from the dataframe gr will be deleted.
c. first 4 rows from the dataframe gr will be deleted.
i. print(df.loc[:'book_name'])
j. print(df['book_name'])
k. print(df[['book_name']])
l. print(df[['book_name','price']])
m. print(df[0:3])
n. print(df[2:4])
o. print(df.iloc[2]))
give he output of the above code : -
Plotting : MATPOTLIB. Matplotlib is a plotting library for the python programming language and its numeric
mathematics extensition numpy. It provides an object oriented API for embedding plots into application using GUI toolkits.
Pylab : Pylab is a package that combines numpy, scipy, matplotlib into a single nameplace.
Line plot : Line plot is type of plot which displays information as a seires of data points called markers connected by straight
line. In this type of plot, we need the measurement points to be ordered.
A bar chart or bar graph is a chart that presets categorical data with rectangular bars with height or length proportional to
the values that they represent.
Histograms are plot type used to show the frequency across a continuous or discrete variable. Histograms are used to show
a distribution where as a bar chart is used to compare different entities.
Example:
import matplotlib.pyplot as plt
student=[1,2,3,4,5]
std1=[81,76,82,92,87]
std2=[65,67,76,87,78]
std3=[56,65,76,87,67]
std4=[56,65,45,34,23]
std5=[77,67,55,67,87]
plt.plot(student,std1,label='student1')
plt.plot(student,std2,label='student2')
plt.plot(student,std3,label='student3')
plt.plot(student,std4,label='student4')
plt.plot(student,std5,label='student5')
plt.xlabel("subject",fontsize=12)
plt.ylabel("marks",fontsize=6)
plt.legend(loc="best",fontsize=10)
plt.title("Student marks",fontsize=16)
plt.axis([0,6,0,100])
plt.grid(which="major",linestyle="-",linewidth='0.5', color="red")
plt.gcf().canvas.set_window_title("Line Graph")
plt.show()
plt.show()
Output:
SQL
1. advantages of DBMS
2. Data independence
3. Primaray keys
4. Foreign key
5. Alternate key
6. Candidate key
7. Composite key
8. Cartisian product
9. Data definition language: DDL statement are used to create and modify the structure of table and other object in
the database. These statements are :- create database, alter database, create table, alter table, drop table, drop
database.
10. Data manipulation language:- DML statements are used to work with data in a table of an existing database. DML
statements are:- select ( is a part of DML), delete , insert, replace, select, truncate, update.
11. Utility Statement:- describe, explain,help, use.
12. Transaction control language:- start transaction, commit, rollback, savepoint, lock tables, unlock tables, set
transaction.
13. Database control language:- these statements are used for database administrator:- these statements are:- grant,
deny, revoke
14. Count() is used to count total number of values in a given column or numbers of columns. Wheare as count(*) is
used to count total number of rows (including null value).