1_ Introduction Python.pptx python is a data

rinkiabhi2014 15 views 92 slides Aug 08, 2024
Slide 1
Slide 1 of 92
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
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92

About This Presentation

python is sometihng that everyone hasd to study for ggsfgdf


Slide Content

Lecture 1: Python – Fundamentals Dr. A. Ramesh DEPARTMENT OF MANAGEMENT IIT ROORKEE

Learning objectives Installing Python Fundamentals of Python Data Visualisation 2

Python Installation Process Installation Process – Step 1: Type https://www.anaconda.com at the address bar of web browser. Step 2: Click on download button Step 3: Download python 3.8 version for windows OS Step 4: Double click on file to run the application Step 5: Follow the instructions until completion of installation process 3

Python Installation Process Installation Process – Step 1: Type https://www.anaconda.com at the address bar of web browser. 4

Python Installation Process Step 2: Click on download button 5

Python Installation Process Step 3: Download python 3.8 version for windows OS 6

Python Installation Process Step 4: Double click on the downloaded file to run the application 7

Python Installation Process 8

Python Installation Process 9

Python Installation Process 10

Python Installation Process 11

Python Installation Process 12

Python Installation Process 13

Python Installation Process 14

Python Installation Process 15

Python Installation Process 16

Why Jupyter NoteBook ? 17 Why? Edit code on web browser Easy in documentation Easy in demonstration User- friendly Interface

Python and Jupyter 18 Python Programming Language Jupyter Application Software Package contains both python and jupyter application

19

About Jupyter NoteBook 20 Cell -> Access using Enter Key

About Jupyter NoteBook 21 Input Field -> Green color indicates edit mode Blue color indicates command mode

About Jupyter NoteBook 22 -> It contains documentation -> Text not executed as code

About Jupyter Notebook Command mode allow to edit notebook as whole To close edit mode (Press Escape key) Execution (Three ways) Comment line is written preceding with # symbol. 23 Ctrl +Enter (Output field can not be modified) Shift +Enter (Output field is modified) Run button on Jupyter interface

About Jupyter Notebook Important shortcut keys 24 A -> To create cell above B -> To create cell below D + D -> For deleting cell M -> For markdown cell Y -> For code cell

Fundamentals of Python Loading a simple delimited data file Counting how many rows and columns were loaded Determining which type of data was loaded Looking at different parts of the data by subsetting rows and columns 25

Importing Different Files in Jupyter Notebook Importing text file 26

Importing Different Files in Jupyter Notebook Importing tablular file 27

Importing Different Files in Jupyter Notebook Importing excel file 28

Importing Different Files in Jupyter Notebook Importing Zip file 29

Importing Different Files in Jupyter Notebook Importing PDF file 30

31

Loading a simple delimited data file 32

33

head method shows us only the first 5 rows 34

Get the number of rows and columns 35

get column names 36

get the dtype of each column 37

Pandas Types Versus Python Types 38

get more information about data 39

Looking at Columns, Rows, and Cells # get the country column and save it to its own variable 40

# show the first 5 observations 41

# show the last 5 observations 42

# Looking at country, continent, and year 43

44

Looking at Columns, Rows, and Cells Subset Rows by Index Label: loc 45

get the first row Python counts from 0 46

# get the 100th row # Python counts from 0 47

get the last row 48

Subsetting Multiple Rows # select the first, 100th, and 1000th rows 49

Subset Rows by Row Number: iloc # get the 2nd row 50

get the 100th row 51

# using -1 to get the last row 52

With iloc , we can pass in the -1 to get the last row—something we couldn’t do with loc . 53

# get the first, 100th, and 1000th rows 54

Subsetting Columns The Python slicing syntax uses a colon, : If we have just a colon, the attribute refers to everything. So, if we just want to get the first column using the loc or iloc syntax, we can write something like df.loc [:, [columns]] to subset the column(s). 55

# subset columns with loc # note the position of the colon # it is used to select all rows 56

57

# subset columns with iloc # iloc will alow us to use integers # -1 will select the last column 58

Subsetting Columns by Range # create a range of integers from 0 to 4 inclusive 59

# subset the dataframe with the range 60

Subsetting Rows and Columns # using loc 61

# using iloc 62

Subsetting Multiple Rows and Columns #get the 1st, 100th, and 1000th rows # from the 1st, 4th, and 6th columns 63

if we use the column names directly, # it makes the code a bit easier to read # note now we have to use loc , instead of iloc 64

65

66

Grouped Means # For each year in our data, what was the average life expectancy? # To answer this question, # we need to split our data into parts by year; # then we get the ' lifeExp ' column and calculate the mean 67

68

69

If you need to “flatten” the dataframe , you can use the reset_index method. 70

Grouped Frequency Counts use the nunique to get counts of unique values on a Pandas Series . 71

Basic Plot 72

73

Visual Representation of the Data Histogram -- vertical bar chart of frequencies Frequency Polygon -- line graph of frequencies Ogive -- line graph of cumulative frequencies Pie Chart -- proportional representation for categories of a whole Stem and Leaf Plot Pareto Chart Scatter Plot 74

Methods of visual presentation of data Table 75

Methods of visual presentation of data Graphs 76

Methods of visual presentation of data Pie chart 77

Methods of visual presentation of data Multiple bar chart 78

Methods of visual presentation of data Simple pictogram 79 West

Frequency distributions Frequency tables 80

Frequency diagrams 81

Histogram 82 Class Interval Frequency 20-under 30 6 30-under 40 18 40-under 50 11 50-under 60 11 60-under 70 3 70-under 80 1

Histogram Construction 83 Class Interval Frequency 20-under 30 6 30-under 40 18 40-under 50 11 50-under 60 11 60-under 70 3 70-under 80 1

Frequency Polygon 84 Class Interval Frequency 20-under 30 6 30-under 40 18 40-under 50 11 50-under 60 11 60-under 70 3 70-under 80 1

Ogive Cumulative Class Interval Frequency 20-under 30 6 30-under 40 24 40-under 50 35 50-under 60 46 60-under 70 49 70-under 80 50 85

Relative Frequency Ogive Cumulative Relative Class Interval Frequency 20-under 30 .12 30-under 40 .48 40-under 50 .70 50-under 60 .92 60-under 70 .98 70-under 80 1.00 86

Pareto Chart 87 10 20 30 40 50 60 70 80 90 100 Poor Wiring Short in Coil Defective Plug Other Frequency 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

Scatter Plot Registered Vehicles (1000's) Gasoline Sales (1000's of Gallons) 5 60 15 120 9 90 15 140 7 60 88

Principles of Excellent Graphs The graph should not distort the data The graph should not contain unnecessary adornments (sometimes referred to as chart junk) The scale on the vertical axis should begin at zero All axes should be properly labeled The graph should contain a title The simplest possible graph should be used for a given set of data

Graphical Errors: Chart Junk 1960: $1.00 1970: $1.60 1980: $3.10 1990: $3.80 Minimum Wage Bad Presentation Minimum Wage 2 4 1960 1970 1980 1990 $  Good Presentation

Graphical Errors: Compressing the Vertical Axis Good Presentation Quarterly Sales Quarterly Sales Bad Presentation 25 50 Q1 Q2 Q3 Q4 $ 100 200 Q1 Q2 Q3 Q4 $ 

Graphical Errors: No Zero Point on the Vertical Axis Monthly Sales 36 39 42 45 J F M A M J $ Graphing the first six months of sales Monthly Sales 39 42 45 J F M A M J $ 36  Good Presentations Bad Presentation
Tags