cs
cs
import pandas as pd
l = [{'name': 'arun', 'age': 21}, {'name': 'bala', 'age': 23}, {'name': 'charan',
'age': 22}]
d=pd.DataFrame(l,index=['s1','s2','s3'],columns=['name','age'])
print(d)
#using nested
import pandas as pd
D={'Arun':65,'Bala':91,'Charan':74,'Dinesh':80,'usha':85}
S=pd.Series(D)
#attributes of dataframe
import pandas as pd
d={'stu_name':['anu','bala','arun','charan','manvi'],'degree':
['mba','mca','me','msc','mca'],'percentage':[90,96,84,75,63]}
df=pd.DataFrame(d,index=['s1','s2','s3','s4','s5'])
print('\nIndex of the DataFrame, df.index:')
print(df.index)
print('\nColumns of the DataFrame, df.columns:')
print(df.columns)
print('\nAxes of the DataFrame, df.axes:')
print(df.axes)
print('\nData types of the DataFrame, df.dtypes:')
print(df.dtypes)
print('\nShape of the DataFrame, df.shape:')
print(df.shape)
print('\nDimension of the DataFrame, df.ndim:')
print(df.ndim)
print('\nTranspose of the DataFrame, df.T:')
print(df.T)
#line chart
import matplotlib.pyplot as plt
weeks=[1,2,3,4]
onion=[45,25,32,80]
brinjal=[16,18,45,50]
plt.title('price analysis')
plt.xlabel('weeks')
plt.ylabel('prices')
plt.plot(weeks,onion,marker='d',markersize=10,color='r',label='onion')
plt.plot(weeks,brinjal,color='g',label='brinjal')
plt.legend()
plt.show()
#histogram
import matplotlib.pyplot as plt
marks=[40,60,56,20,35,70,60,89,90,33]
plt.title('maths marks histogram of class x11')
plt.xlabel('marks ranges')
plt.ylabel('no of students')
plt.hist(marks,bins=[0,33,45,60,100],edgecolor='red')
plt.show()
mysql> select name ,salary from info where salary>15000 and gender<>'m';
+-------+--------+
| name | salary |
+-------+--------+
| usha | 25000 |
| nisha | 18000 |
+-------+--------+
update info set salary =salary=(salary*0.10)where city='chennai' and gender='m';
Query OK, 2 rows affected (0.01 sec)
use stu;
Database changed
mysql> desc st;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| rollno | int | NO | PRI | NULL | |
| name | varchar(10) | YES | | NULL | |
| gender | varchar(2) | YES | | NULL | |
| age | int | YES | | NULL | |
| dept | varchar(10) | YES | | NULL | |
| doa | date | YES | | NULL | |
| percentage | float | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
7 rows in set (0.01 sec)