Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCING PYTHON PANDAS:-SERIES

Similar presentations


Presentation on theme: "INTRODUCING PYTHON PANDAS:-SERIES"— Presentation transcript:

1 INTRODUCING PYTHON PANDAS:-SERIES
SUBMITTED TO:-VIJETA DARA MAM SUBMITTED BY:-AMAN SAINI

2 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

3 CREATING SERIES OBJECT

4 1. CREATING EMPTY SERIES

5 2.CREATING SERIES USING ARRAY

6 USING ZEROS()

7 USING ONES()

8 USING ARANGE()

9 3. USING DICTIONARY

10 4.Using scalar values

11 ADDITIONAL FUNCTION

12 1.ADDING NaN VALUES

13 2.SPECIFY INDEXES AS WELL AS DATA

14 3.SPECIFY DATA WITH DATA TYPE

15 4.USING MATHEMATICAL EXPRESSION/FUNCTION

16 SERIES OBJECT ATTRIBUTES

17 Series.index:-The size of the series

18 Values:- return series as nd array

19 Dtype:- returns datatype of list

20 Shape:- return shape of series data

21 Nbytes:- return number of bytes

22 Ndim:-returns number of dimension

23 Size:-returns number of element

24 Itemsize:-return size of datatype

25 Hasnans:-return true if there ia any nan values

26 Empty:-return true if series object ia empty

27 ACCESSING INDIVIDUAL ELEMENT

28 SLICES FROM SERIES OBJECT

29 HEAD() AND TAIL() FUNCTION:- First 5 or last 5 element is taken as default

30 VECTOR OPERATION ON SERIES
sr+2 sr*3

31 Sr1=sr**2 Sr>15

32 ARITHMETIC ON SERIES OBJECT
Sr+sr1(if index are same) Sr+sr1(if index are not same)

33 DIFFERENCE BETWEEN NUMPY AND SERIES
In nd array ,the indexes are always numeric starting from zero onwards. Series object can have any type of index including number, letter, string, labels, In case of nd array we can perform vector operation only if there shape match otherwise it returns error In case of vectorise operation the data of two series are aligned as per matching index and operation is perform then and non matching index return NaN

34 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* (b)N* (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

35 Application based question
1.Consider following series object namely S: 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 ?

36 2. Consider the same series object S, given in previous question
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’]= 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+s 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]= (e) print(s.index) print(s) print(s.values)

37 5. Find the error: (a) s2=pd. Series([101,102,103,104]) print(s2
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]= 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))

38 THE END


Download ppt "INTRODUCING PYTHON PANDAS:-SERIES"

Similar presentations


Ads by Google