780 likes | 1.17k Views
INTRODUCING PYTHON PANDAS:-SERIES. SUBMITTED TO:-VIJETA DARA MAM SUBMITTED BY:-AMAN SAINI. PANDAS DATA STRUCTURE. DATA STRUCTURE:- It refers to specialized way of storing data so as to apply a specific type of functionality on them.
E N D
INTRODUCING PYTHON PANDAS:-SERIES SUBMITTED TO:-VIJETA DARA MAM SUBMITTED BY:-AMAN SAINI
PANDAS DATA STRUCTURE DATA STRUCTURE:- It refers to specialized way of storing data so as to apply a specific type of functionality on them. SERIES:- A series is pandas data structure that represent a one dimensional array like object containing an array of data (of any NumPy data type) and an associated array of data labels, called is index
HEAD() AND TAIL() FUNCTION:- First 5 or last 5 element is taken as default HEAD TAIL
VECTOR OPERATION ON SERIES sr+2 sr*3
Sr1=sr**2 Sr>15
ARITHMETIC ON SERIES OBJECT Sr+sr1(if index are same) Sr+sr1(if index are not same)
Assignments • What is the significance of pandas library. • Name some common data structure of python pandas library . • If a python list is having 7 integer and a numpy array is also having 7 integer, then how are these two data structure similar or different from one another ? • Given a list=[3,4,5] and an ndarray N having elements 3,4,5.What will be the result produced by : (a)L*3 (b)N*3 (c)L+L (d)N+N 5. Write code to create an ndarray having six zeros in it. Write statements to change 3rd and 5th elements of this ndarray to 15 and 25 respectively
Application based question 1.Consider following series object namely S: 0 0.430271 1 0.617328 2 -0.265421 3 -0.836113 What will be returned by following statement ? (a) S*100 (b) S>0 (c)S1=pd.Series(S) (d)S3=pd.Series(S1)+3 What will be the values of Series object S1 and S3 created above ?
2.Consider the same series object S, given in previous question. What output will be produced by following code ? S.index=[‘AMZN’,’AAPL’,’MSFT’,’GOOG’] print(S) print(S[‘AMZN’]) S=[‘AMZN’]=1.5 print(S[‘AMZN’]) print(S)3.What will be the output of following code ? Stationery=[‘pencils’,’notebooks’,’scales’,’erasers’] s=pd.Series([20,33,52,10],index=Stationery) s1=pd.Series([17,13,31,32],index=Stationery) print(s+s1) s=s+s2 print(s+s2)4.What will be the output produced by following code, considering the Series object s given above ? (a) print(s[1:1]) (b) print(s[0:1]) (c) print(s[0:2]) (d) s[0:2]=12 (e) print(s.index) print(s) print(s.values)
5.Find the error: (a) s2=pd.Series([101,102,103,104]) print(s2.index) s2.index=[0,1,2,3,4,5] s2[5]=220 print(s2) (b) s=pd.Series(2,3,4,5,index=range(4) ) (c) s1=pd.Series(1,2,3,4,index=range(7) ) (d) s2=pd.Series([1,2,3,4],index=range(4) )6. Find the error and correct it: data=np.array([‘a, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’]) s=pd.Series(data,index=[100,101,102,103,104,105] print(s[102,103,104])7. Why does the following code cause error ? S=pd.Series(range(1,15,3),index=list(‘abcd’))8. Why does the following code cause error ? S=pd.Series(range(1,15,3),index=list(‘ababa’)) print(s[‘ab’])9. If Ser is a series type object having 30 values, then how r statement (a),(b),(c) and (d) similar and different ? (a) print(Ser.head()) (b) print(Ser.head(8)) (c) print(Ser,tail()) (d) print(Ser.tail(8))