INTRODUCING PYTHON PANDAS:-SERIES

Slides:



Advertisements
Similar presentations
Multidimensional Array
Advertisements

String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Beyond Lists: Other Data Structures CS303E: Elements of Computers and Programming.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 9 Arrays.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Built-in Data Structures in Python An Introduction.
Course A201: Introduction to Programming 09/30/2010.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Sum of Arithmetic Sequences. Definitions Sequence Series.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
Lesson 3 Functions. Lesson 3 Functions are declared with function. For example, to calculate the cube of a number function function name (parameters)
Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.
String and Lists Dr. José M. Reyes Álamo.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Based on slides by Shawn.
Chapter 11 - JavaScript: Arrays
PH2150 Scientific Computing Skills
Review Array Array Elements Accessing array elements
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Numpy (Numerical Python)
Chapter 2 - Introduction to C Programming
Containers and Lists CIS 40 – Introduction to Programming in Python
Debugging and Random Numbers
Numeric Arrays Numeric Arrays Chapter 4.
A simple way to organize data
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Student Book An Introduction
2. Understanding VB Variables
Chapter 2 - Introduction to C Programming
ARRAYS.
11/10/2018.
Pointers and Arrays S.Bhuvaneshwari Assistant Professor/CSE
Introduction to Python
Chapter 2 - Introduction to C Programming
Lists in Python.
Console input.
PH2150 Scientific Computing Skills
Matlab tutorial course
Chapter 2 - Introduction to C Programming
Lecture 18 Arrays and Pointer Arithmetic
Web DB Programming: PHP
Numpy (Numerical Python)
CEV208 Computer Programming
String and Lists Dr. José M. Reyes Álamo.
Numpy (Numerical Python)
MATLAB Programming Indexing Copyright © Software Carpentry 2011
Chapter 2 - Introduction to C Programming
Data Types and Data Structures
Differences between Java and C
CMSC202 Computer Science II for Majors Lecture 03 – Arrays and Functions Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
CIS16 Application Development and Programming using Visual Basic.net
mdul-cntns-sub-cmmnts2.f90
Arrays in Java.
Python Basics with Jupyter Notebook
Chapter 2 - Introduction to C Programming
Dr. Sampath Jayarathna Cal Poly Pomona
Exercise Arrays.
And now for something completely different . . .
Introduction to Computer Science
Dr. Sampath Jayarathna Old Dominion University
Dr. Sampath Jayarathna Old Dominion University
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/11.
8.3 Vectors Copyright © 2008 Pearson Addison-Wesley. All rights reserved. 1.
DATAFRAME.
Karan Thaker CS 265 Section 001
Presentation transcript:

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

CREATING SERIES OBJECT

1. CREATING EMPTY SERIES

2.CREATING SERIES USING ARRAY

USING ZEROS()

USING ONES()

USING ARANGE()

3. USING DICTIONARY

4.Using scalar values

ADDITIONAL FUNCTION

1.ADDING NaN VALUES

2.SPECIFY INDEXES AS WELL AS DATA

3.SPECIFY DATA WITH DATA TYPE

4.USING MATHEMATICAL EXPRESSION/FUNCTION

SERIES OBJECT ATTRIBUTES

Series.index:-The size of the series

Values:- return series as nd array

Dtype:- returns datatype of list

Shape:- return shape of series data

Nbytes:- return number of bytes

Ndim:-returns number of dimension

Size:-returns number of element

Itemsize:-return size of datatype

Hasnans:-return true if there ia any nan values

Empty:-return true if series object ia empty

ACCESSING INDIVIDUAL ELEMENT

SLICES FROM SERIES OBJECT

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

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)

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

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 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 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))

THE END