0% found this document useful (0 votes)
9 views

Python Class 2

M.com (Business Finance)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Class 2

M.com (Business Finance)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

HELLO

EVERYONE
Welcome to another boring round of python

Lets call this Python


basics
AGENDA
 Rewind the previous class
 Jupyter basics
 Working Simple delimited data file
BASIC DESIGN JUPYTER
NOTEBOOK

Change it from code to


Input field markdown for documentation
purpose

The green and blue colors in the cell denotes the cell is
in edit mode and command mode respectively.
BASICS ON JUPYTER
 Command mode helps to edit notebook
as a whole.
 To close edit mode use ‘Esc key’ and
open edit mode press ‘enter key’
 Execution #3 ways
 Ctrl+enter – Outside field cannot be
modified
 Shift+Enter – Outside field can be
modified
 Run button on Jupyter interface.

Cammand line is written preceding with #


symbol.
IMPORTANT SHORTCUT
KEYS IN JUPYTER

 A – To create cell above


 B – to create cell below
 DD- to delete the selected cell
 M – to markdown cell
 Y – for code cell
 F – Find and replace
THERE ARE NUMEROUS
SHORTCUT KEYS
LOADING A SIMPLE
DELIMITED DATA FILE
 We use 3 libraries
 Pandas- paneled data set
 Numpy
 Matplotlib.pyplot
TO FIND THE HEADING OF
THE COLUMNS
 Dataset.head()
TO KNOW THE SIZE OF THAT FILE
 Dataset.shape
TO KNOW THE DIFF
COLUMN NAMES
 Print(dataset.columns)
TO DISPLAY THE DATATYPES
OF ALL THE COLUMNS
 Print(dataset.dtypes)
TO GET MORE INFO
ABOUT THE DATA
 Print(dataset.info)
LOOKING AT COLUMNS,
ROWS AND CELLS
 #get country column and save it in its
own variables
 Country_dataset=dataset[‘country’]
 To see the first five rows
 print(country_dataset.head())
 #To see the last five rows of the column
country
 print(country_dataset.tail())
TO DISPLAY MULTIPLE
COLUMNS
 Subset=dataset[[‘country’,’continent’,’yea
r’]]
 Print(subset.head())
 Print (subset.tail())
LOCATE A PARTICULAR
ROW
 #for that we use loc[]
 Print(dataset.loc[0])
TO GET THE LAST ROW
Print(dataset.tail(n=1))
#you will get the last row

#to access 1st, 100th, 1000nd row


Print(dataset.loc[[0,99,999]])
ILOC CAMMAND
 Loc selects rows and columns with
specific integer positions
 iloc selects rows and columns at specific
integer positions.
 In iloc even minus values can be used
 #Get 2nd row
 Print(dataset.iloc[1])
 #Get 1st, 100th, 1000th row
 Print(dataset.iloc[[0,99,999]])
 # using -1 to get the last
row
 Print(dataset.iloc[-1])
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 loc or iloc syntax, we can
write something like df.loc[:,[columns]]
to subset the column(s).
subset=dataset.loc[:,['year','pop']]
print(subset.head())
 To get the basic summary statistics
dataset.describe()
 To get for a single variable Ex:
GdpPercap
dataset[‘gdpPercap’].describe()
 To get the mean or median of a single
variable
data['gdpPercap'].mean()
dataset[‘gdpPercap’].median()
 To make a Scater plot of the data
plt.scatter(data.gdpPercap, data.lifeExp)
plt.show()
REGRESSION
 To make a scatter plot
plt.scatter(dt.area, dt.price)
plt.show()
 To change the colour of the chart and
marker
plt.xlabel('area’) # to add labels
plt.ylabel('price’)
plt.scatter(dt.area, dt.price, color='red',
marker='*’)
plt.show()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy