Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

Python For Data Scince

Python is a popular programming language for data science due to its versatility, extensive libraries, and easy-to-learn syntax.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Python For Data Scince

Python is a popular programming language for data science due to its versatility, extensive libraries, and easy-to-learn syntax.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

PYHTON FOR DATA SCINCE

WHAT IS PYTHON ?
Python is a popular programming language. It was created by Guido van Rossum, and released
in 1991.
It is used for:
•web development.
•software development,
•mathematics,

•System scripting. (System scripting is a collection of commands used to execute like a


program).

•Python can be used on a server to create web applications.


•Python can be used alongside software to create workflows.
•Python can connect to database systems. It can also read and modify files.
•Python can be used to handle big data and perform complex mathematics.
Why we use python?
• Python has a simple syntax similar to the English language.
• Python has a syntax that allows developers to write programs with fewer lines than some other
programming languages.

• What is a variable?

We can say that variables in Python are containers that store values.
 X=“Sufyan”
 Print(x)
 Sufiyan
Comments?
 In Python, there are two types of comments:
• Single-line comment.(#)
• multi-line comment.(‘’’)
Python Operators
 Operators are used to perform operations on variables and values.
 In the example below, we use the + operator to add together two values:
 There are many types of operators.
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
Arithmetic Operators
 Arithmetic operators are used with numeric values to perform common mathematical operations:

 Operator Name Example


 + Addition x+y
 - Subtraction x-y
 * Multiplication x*y
 / Division x/y
 % Modulus x%y
 ** Exponentiation x ** y
 // Floor division x // y
Assignment Operators
 Assignment operators are used to assign values to variables:
 Operator Exam Same As
 = x=5 x=5
 += x += 3 x=x+3
 -= x -= 3 x=x-3
 *= x *= 3 x=x*3
 /= x /= 3 x=x/3
 %= x %= 3 x=x%3
 //= x //= 3 x = x // 3
 **= x **= 3 x = x ** 3
 &= x &= 3 x=x&3
 |= x |= 3 x=x|3
 ^= x ^= 3 x=x^3
 >>= x >>= 3 x = x >> 3
Condition statement
We have decisions making in this condition
For example, if we are tired then we will not go for walk if we are not tired then we will for walk
In the program we have also take decision that's names are if ,elif,else
User=int(input("enter a number which is greater then 5.. or 5...:"))
If user==5:
print("you are selected right number ")
elif (user > 5):
print("you are selected right number ")
Else:
Print("you are selected wrong number ")
what is a data type?
Python Data Types are used to define the type of a variable. It defines what type of data we are going to store in a variable.
What is a string in Python?
 String is a collection of alphabets, words, or other characters.
 Print("hello")
 hello
 For example, "hello" is a string containing a sequence of characters 'h', 'e', 'l', 'l', and 'o'. Here, we
have created a string variable

Number: There are three types of number : integers, floating point numbers, and
complex numbers.
 Integers:20,30,40
 Float:35.5,38.2,26.4
 Complex:1+3j
What is list in python?
 A Python list is an ordered and changeable collection of data objects and we use a square
bracket for the list.
 Ex:list1= [2,4,,5,6,7,8]. List Function
 Print(list1). append().min().max()
 =2,4,5,6,7,8. Len().del().remove().pop()

What is a tuple in Python?


 A is a collection of objects which ordered and immutable.
 The differences between tuples and lists are, that the tuples cannot be changed unlike lists and tuples use
parentheses, whereas lists use square brackets.
 Ex:tup1=(1,2,3,4,5)
 Print(tup1)
 =1,2,3,4,5. TUPLE FUNCTION
 sum().min().max()
 Index()..len().etc
What is a dictionary in python?
 Dictionaries are mutable data structures that allow you to store key-value pairs dictionary cannot have two items
with the same key,and we use curly brackets in the dictionary.
 Ex=dict1={
 “name1”: “Sufyan:”,
 “name2”: “Noorani”
 }

What is set in Python?


Sets are used to store multiple items in a single variable. A set is a collection that is unordered, unchangeable, and
unindexed.
Ex:set1={“Sufiyan”,”Noorani”}
 Print(set1)
 {‘Sufiyan’,’Noorani’}. Sets FUNCTION
 set().add().pop()
 remove().discard()
 update().etc
inheritance
 When we make a class and we want to access that class’s properties in another class we use
inheritance
 Types of inheritance
 1 single inheritance
 Multiple inheritance
 Multilevel inheritance
 Hierarchical inheritance
 Hybrid inheritance
 EXAMPLE OF SINGLE INHERITANCE
 Class Mycar:
 def Myfun(self):
 print("we make a class it name is Mycar")
 Class Name(Mycar):
 def fun(self)
 Object=Name()
 Object.Myfun()
What is NumPy?

 NumPy is a Python library used for working with arrays.


 NumPy aims to provide an array object that is up to 50x faster than traditional Python lists.
 We use Numpy because it provides efficient storage Numpy is so fast
 Example
 Import numpy as np
 A=np.array
 Numpy function
 ndim(),eye(),zeros()
 Empty(),ones()
 Etc
import numpy as np
Numpy Function
s=np.array([[[1,2,3],[4,5,6],[7,8,9]]])
print(s[0,0,1])
print(s[0,1,2])
print(s[0,2,2])
print(s)
print()
a=np.zeros(3)
print(a)
a1=.eye(4)
print(a1)
a2=np.empty(4)
print(a2)
a3=np.full((2,3),4)
print(a3)
s1=np.append(s,a3)
print(s1)
s2=np.size(s)
print(s2)
s3=np.shape(s)
print(s3)
s4=np.arange(1,4,2)
print(s4)
s5=np.argmax(s)
print(s5)
Pandas

 Pandas is a Python library used for working with data sets.


 It has functions for analyzing, cleaning, exploring, and manipulating data.
 Pandas allow us to analyze big data.
 Pandas can clean messy data sets, and make them readable and
relevant.
 Relevant data is very important in data science.
 import pandas as pd
 a={ ("Sun","23/02/2019","23°",1003),
 ("mon","24/02/2019","22°",10002)}
 p=pd.DataFrame(a,columns=["day","Date",
 "Tem","pressure"])
 print(p)
we can read file CSV or EXCEL
Pandas function
a=pd.read_csv("file path".CSV)
we can skiprow and columns
a=pd.read_csv("file path.csv" ,skiprows=[0,1]. Then row 0 and 1 skip
We can make file
dic={("sun","12/09/1901",12,1000),
("Mon","13/09/1901",12,1001)}
a=pd.to_csv(dic)
We can skip index and take index place columns
a=pd.read_csv("file path.csv" ,indexcol=[columns name])
We can get columns
a=pd.read_csv("file path.csv")
a.columns=[columns name]
we can get 5, row from upper
M=pd.head(a)
Pandas Function
We can get 5 row from reverse
a=pd.tail()
In pandas have Series ===> Series is use to make 1 dimensions
a=pd.Series(n)
In pandas we can change haed
a=pd.read_csv("file path.csv",names=[ "header name"])

You might also like