Python For Data Science AI Development
Python For Data Science AI Development
String Operations
positive index → to access element from start to end
stride
length
len(string)
replication
string is immutable
escape sequence
\n # new line
\t # tab
\\ # just backslash
list = [1, 2, 3, 4]
list.extend([5, 6]) # [1, 2, 3, 4, 5, 6]
list.append(5) # [1, 2, 3, 4, 5]
Dictionaries
dictionary has key and value
keys are immutable and unique
dict = {}
dict.keys() # keys
dict.values() # values
dict["key"] # some value
"key" in dict # give `True` or `False`
Sets
set holds unique elements
set = {1, 2, 3, 4, 5}
set.add(6) # {1, 2, 3, 4, 5, 6}
a == b # is equal?
a < 6
a != b # is not equal?
Loops
Functions
Exception Handling
try:
...
...
except:
... # handle error
else:
... # task is done successfully
type
methods
class Circle(object):
def __init__(self, color, radius):
self.radius = radius
self.color = color
class Rectangle(object):
def __init__(self, color, height, width):
self.height = height
self.width = width
self.color = color
import pandas as pd
df = pd.read_csv(<path>) # load dataframes
df.head() # give header of csv
import numpy as np
a = np.array([0, 1, 2, 3, 4]) # create a numpy array
a.size # 5
a.ndim # 1 (number of dimension)
a[1:4] # [1, 2, 3]
Webscraping
webscraping → process that can be used to extract information
from a website and cen easily be accomplished within a matter of
minutes
https://drive.google.com/file/d/1ksdgaz4rurbd0C_uVyFEPozJe4
ISWh4q/view?usp=drive_link