PPT data science python sequence numpy.pptx

AkashAgrawal434750 20 views 11 slides May 05, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

Data science


Slide Content

Python for Data Science Week 2

What we learnt this week ? Sequence Data Types Strings Lists Tuple Dictionary Sets Numpy

What are Sequence Data Types ? Sequence Data Types allows us to store multiple values in an organized and efficient fashion. String, List, Tuple are some example of Sequential types Dictionaries and Sets are container for Non-sequential data.

Strings String is  an immutable sequence data type. Immutable – which can’t be changed It is the sequence of Unicode characters wrapped inside single, double, or triple quotes . Example: ‘This is a string in Python’ “This is a ‘string’ in Python” ‘“This is a “string” in Python”’

Functions/Methods on String string*n - repeats the given string n times u pper() - Converts a string into upper case lower() - Converts a string into lower case s plit() - Splits the string at the specified separator, and returns a list i ndex() - Searches the string for a specified value and returns the position of where it is found c ount() - Returns the number of times a specified value occurs in a string capitalize() – Returns the string with its first character capitalized and the rest lowercased

Lists A list is  an ordered and mutable Python container. Lists are used to store multiple items in a single variable . Lists are created using square brackets Example: myList = [1 , 2 , 3 , 4 , 5] myList = [1 , ‘two’ , 3 , ‘four’ , 5] myList = [1 , [‘a’ , ‘b’ , ‘c’] , ‘hello’]

Functions/Methods on Lists append() - Adds an element at the end of the list pop() - Removes the element at the specified position clear() - Removes all the elements from the list insert() - Adds an element at the specified position reverse() - Reverses the order of the list extend() - Add the elements of a list (or any iterable), to the end of the current list

Dictionary U sed to store data values in key:value pairs . Dictionaries are written with curly brackets, and have keys and values Syntax:- { 'key1':'value1','key2':'value2 '} Duplicates not Allowed Dictionaries cannot have two items with the same key. Example mydictionary = {   "brand": "Ford",   "model": "Mustang",   "year":  1964 }

Numpy and Numpy Array Numpy is a Python package and it stands for numerical python. A numpy array is a grid of values, all of the same type. To install numpy on your system, run this command on your CMD pip install numpy To create numpy array, we first need to import the numpy package: import numpy as np Example:- array = np.array([1,2,3,4,5], dtype = int )

Methods/Functions type(array) – this will give you the Datatype of Array len(array) – length of array array.ndim - return the number of dimensions of an array a rray.shape - returns a tuple with each index having the number of corresponding elements array.reshape – it changes the shape of the array

Thank You For your Patience
Tags