This tutorial is for absolute beginners in Python. Python is a general purpose, open source programming language that is very popular. Python is also an interative programming, that means you can directly get the results of your code.
Here is an example to use Python as a calculator
1+2+3+4+5
Use input(strMessage) to get input from user. The program will wait for the user to type some text or number on the keyboard and press enter.
a=input("enter a number: ")
Use print(list of string) function to displays the string value inside the parentheses on the screen. When print() function is used together with input() function, the print will be done only after the user input.
print('What is your name?')
name=input()
print('Your name is ' + name)
Python has several primitive data types:
Python also has collection of the primitive data type such as
We will discuss the collection of primitive data types in later sections.
Here are some examples of the primitive data types. Note: symbol # is the start of a comment that will not be executed by Python
1,2,3 # integers
1.1, 2., 3.6 # floats
'1', 'abc', '3.6' # strings
True, False, 1==2, 3.5==3.5 # Boolean
complex('1+2j')+complex('3+5j') # complex numbers
You can store the value of an integer, float or string into a variable as the following example
a=2
b=3+a
c=b-a
c
Name of variables (and functions and classes) are case sensitive.
In Python you can assign multiple values at once.
a,b,c=1,2,3
d=[a,b,c]
d
a=b=c=0
d=[a,b,c]
d
To swap two values, we simply do the following:
a=3
b=5
a,b=b,a
print(a,b)
You can convert a value into a string using function str().
You can convert a value into an integer using function int().
You can convert a value into a float using function float().
You can convert a value into a float using function bool().
You can convert a value into a float using function complex().
str(3)
int(3.45)
float('2.5')+2.5
bool(3)
complex(3,5)
Numerical operators are either used toward one or two values and produce a single value.The following are numerical operators and most useful numerical functions.
operator | Description |
x + y | sum of x and y |
x - y | difference of x and y |
x * y | multiplication of x and y |
x / y | division of x and y |
x % y | remainder of x / y (modulus) |
x // y | floored quotient of x and y (integer division) |
abs(x) | absolute value or magnitude of x |
-x | x negated |
+x | x unchanged |
x ** y | x to the power y |
pow(x, y) | x to the power y |
math.sqrt(x) | square root of x |
math.floor(x) | the greatest integer <= x |
math.ceil(x) | the least integer >= x |
math.trunc(x) | x truncated to integer |
round(x[, n]) | x rounded to n digits, rounding half to even. If n is omitted, it defaults to 0. |
divmod(x,y) | the pair (x // y, x % y) |
int(x) | convert x to integer |
float(x) | convert x to float |
complex(re,im) | convert x to complex number |
c.conjugate() | conjugate of the complex number c |
import math
x=-30; y=2.1
print(str(x) + "+" + str(y) + " = ",x+y)
print(str(x) + "-" + str(y) + " = ",x-y)
print(str(x) + "*" + str(y) + " = ",x*y)
print(str(x) + "/" + str(y) + " = ",x/y)
print(str(x) + "%" + str(y) + " = ",x%y)
print("abs("+ str(x) +") = ",abs(x))
print("-" + str(y) + " = ",-y)
print("+" + str(y) + " = ",+y)
print(str(x) + "**" + str(y) + " = ",x**y)
print("pow(" + str(x) + "," + str(y) + ") = ",pow(x,y))
print("math.sqrt("+str(-x) + ") = ",math.sqrt(-x)) # only for positive number
print("math.floor(math.sqrt("+str(-x) + ")) =",math.floor(math.sqrt(-x)))
print("math.ceil(math.sqrt("+str(-x) + ")) =",math.ceil(math.sqrt(-x)))
print("math.trunc("+str(y) + ") =",math.trunc(y))
print("divmod("+str(x) + "," + str(y) + ") = ",divmod(x,y))
print("int("+ str(y) + ") = ",int(y))
print("float("+ str(x) + ") = ",float(x))
print("complex("+ str(x) + "," + str(y) + ") = ",complex(x,y))
print("complex("+ str(x) + "," + str(y) + "),conjugate() = ",complex(x,y).conjugate())
operator | Description |
x += y | x = x + y |
x -= y | x = x - y |
x *= y | x = x * y |
x /= y | x = x / y |
x %= y | x = x % y |
x=-30; y=2.1
x+=y
print("x = ",x,"; y = ",y)
x=-30; y=2.1
x-=y
print("x = ",x,"; y = ",y)
x=-30; y=2.1
x*=y
print("x = ",x,"; y = ",y)
x=-30; y=2.1
x/=y
print("x = ",x,"; y = ",y)
x=-30; y=2.1
x%=y
print("x = ",x,"; y = ",y)
You can use comparison operators to compare two values and return to a single Boolean value. The following are comparison operators
== | Equal to |
!= | Not equal to |
< | Less than |
> | Greater than |
<= | Less than or equal to |
>= | Greater than or equal to |
An integer is treated equal as float if they have the same value. String are not treated equal to number. You cannot compare number and string. See the following examples.
23==23.0 # the same value, thus treat integer is equal to float
23==23.5 # not the same value
23=='23' # number is not equal to string
23<=23.5 # you can compare integer and float
Bitwise operation applied to positive integers. The integers are converted to binary, then apply the operator and converted back to decimal. Three main bitwise operators are
Operator | Description |
x & y | bitwise and |
x | y | bitwise or |
x ^ y | bitwise xor |
~ x | bitwise inversion of x which is equal to -(x+1) |
x >> y | bitwise shift right will returns x with the bits shifted to the right by y places |
x << y | bitwise shift left will returns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). This is the same as multiplying x by 2**y. |
Example:
Decimal | Binary | Description |
2 | 010 | x = first Operant |
5 | 101 | y = second Operant |
0 | 000 | x & y = result |
Decimal | Binary | Description |
2 | 010 | x = first Operant |
5 | 101 | y = second Operant |
7 | 111 | x | y = result |
Decimal | Binary | Description |
2 | 010 | x = first Operant |
5 | 101 | y = second Operant |
7 | 111 | x ^ y = result |
Distinguish bitwise operation from Logical Operation and Set operation
x, y =2,5
print("bin(" +str(x)+")="+bin(x),"; bin(" + str(y) + ") = "+bin(y))
print(str(x) + "&" + str(y) + " = ", x&y)
print(str(x) + "|" + str(y) + " = ", x|y)
print(str(x) + "^" + str(y) + " = ", x^y)
print("~" + str(x) + " = ", ~x)
print(str(x) + ">>" + str(y) + " = ", x>>y)
print(str(x) + "<<" + str(y) + " = ", x<<y)
Notice in the example above that the bitwise not produce negative value because python applies it to signed integer. If you want to use for image processing, the following bitwise not is useful.
def bitwise_not(n, numbits=8):
return (1 << numbits) - 1 - n
bitwise_not(2)
Three main logic operators are and, or, not.
not True
True and False
True or False
When logical operator is applied into number, a non-zero is considered as True. Zero is considered as False. Logical not of a non-zero would be False. Not 0 would be True. If both operants are non-zero:
x, y = 1,-2
print(str(x) + " and " + str(y) + " = ", x and y)
print(str(x) + " or " + str(y) + " = ", x or y)
print("not " + str(y) + " = ",not y)
Comparison can be chained, but the evaluation is every pair. As if there is and between the two.
a=5
2<a<6 # equal to (2<5) and (5<6)
0<=a<2 # equal to (0<=a) and (a<2)
Operator in return True if it find a variable in a specified sequence.
'good' in 'Apple has a good taste'
'bad' not in 'Durian has bad odor'
Operator is return True if the variables on either side of the operator point to the same object.
a=234
b=a
a is b # return True because both variables a and b are pointing to the same object
a=123.5
b=123.5
a is b # rteurn False even if the same value because not the same object
Watch out: is operator will return True if they have the same value. This behavior is only correct for integer and string
a='123'
b='123'
a is b # is operator will return true if they have the same value only for integer and string
a=123
b=123
a is b
Every object has a boolean value. The following elements are False:
All other values are considered True
a=23
if a==23:
print('it is my number!')
If-then statement is similar to a mathematical function $ f=\begin{cases} & \textrm{'Good morning!'} \text{ if } a= \textrm{'hello'}\\ & \textrm{'Good afternoon!'} \text{ if } a\neq \textrm{'hello'} \end{cases} $
a='helloo'
if a=='hello':
print('Good morning!')
else:
print('Good afternoon!')
if-elif-else statement is similar to a mathematical function $ f=\begin{cases} & \textrm{'negative number'} \text{ if } x < 0\\ & \textrm{'zero'} \text{ if } x = 0\\ & \textrm{'positive number'} \text{ if } x > 0 \end{cases} $
x=-231.12
print(x)
if float(x)<0:
print('negative number')
elif float(x)==0:
print('zero')
else:
print('positive number')
The following flow control are used to repeat or to iterate in Python:
the following statements are useful to break or continue the loop:
To show the values in a range, use list(range(start [, end][, step])). The end is exclusive while the start is inclusive.
list(range(1,10,2))
list(range(2,5))
list(range(5))
fruits = ['apple', 'banana', 'cherry', 'durian']
for f in fruits:
print(f, len(f)) # built-in function len is to count the number of characters in a word
for k in range(5):
print(k)
for num in range(1, 10):
if num % 2 == 0:
print(num, "is an even number")
continue
print(num, "is an odd number")
A loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes False (with while), but not when the loop is terminated by a break statement.
for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(n, 'equals', x, '*', n//x)
break
else:
print(n, 'is a prime number')
a=0
while a<5:
print(a)
a=a+1
a=0
while True:
if a>=5:
break
else:
a+=1
print(a)
In Python, you can construct a list by writing the criteria based on sequence S.
Syntax:
square=[x**2 for x in range(10)] # return list of square integers
square
[x for x in square if x%2==0] # return list of even square integers
A list is comma-separated values (items) between square brackets []. Think of a list as an array of ordered sequence. The index of the array start from 0. List is a mutable data type. You can add value, remove and change the items in a list.
x=[1,2,3]
y=[4,5,6]
x+y
for x in [4,5,6]: print(x)
x=['Hello ']
x*4
m = "Peter"
a=[1,2,3,'Paul',2.35,m]
a
We can change assign values to the element of the list:
a[0]='Peter'
a
To add at the back of a list, use append() method.
a.append('last')
a
Use len() function to check the total number of elements in a list.
len(a)
We can remove the element of a list using del
del(a[1:3])
a
We can also remove an element using remove() method
a.remove(2.35)
a
We can use insert(position, object) method to put an object at some index position.
a.insert(4,'last')
a
We can use sort() method to sort a list. Sorting only happens if the data type are the same for all items in the list.
a.sort()
a
Another way to sort a list is to use Python built-in function sorted().
sorted(a)
a.reverse()
a
we can also use count() method to count how many times the objects happen in a list
a.count('Peter')
A list can be nested and the number of element is not necessarily the same.
x=[['a'],['b','c'],['d','e','f']]
x
A list can be generated over a function
y=[1,2,3,4,5]
def f(x):
return x**2
[f(x) for x in y]
A list can be constructed using for loop.
[y+1 for y in range(5)]
x=[1,3,5,9]
[2 + y*2 for y in x if y>=3]
x=[1,2,3]
[[a,b] for a in x for b in x]
The zip() function turns n lists (list1, list2, ...) into one list of n-tuples, where each n-tuple (a,b,...) has its first element (a) from the first list (list1), the second element (b) from the second list (list2), and so forth.
x=[1,2,3]
y=[4,5,6]
[[a,b] for a,b in zip(x,y)]
To copy a list, use Python module name copy.
import copy
y=[100,67,56,12,99]
x=copy.copy(y)
x[0]=101
print(y,x)
To make the layout nicer and more readable, use pprint module that offers a pretty print functionality.
import pprint
x=[1,3,4,7]
table=[[a,b] for a in x for b in x]
pprint.pprint(table)
A list can be sliced using colon notation (start:end:step). Similar to range(), the start is inclusive and the end is exclusive. If the start is omitted, it starts from beginning of the list. If the end is omitted, it enumerate up to the end of the list. If the step is omitted, the step=1.
The index of a list start with 0. Negative index means it starts from the back.
b=range(1,15)
list(b)
list(b[2:10:2])
list(b[-1:9:-1])
b=[3, 3.5, 4.2, 8.1]
b[2:]
b[:3]
b[1:3]
x=[1,3,4,7]
table=[[a,b] for a in x for b in x]
table[0:6]
table[0:6][3:]
A tuple is an an ordered sequence, similar to a constant list. However, a list is mutable data type while a tuple is immutable data type. Once a tuple is defined, we cannot modify, append or remove any item. Tuple is denoted by parentheses. String data type in Python behaves like tuple.
x=(1,2,3)
y=(4,5,6)
x+y
for x in (4,5,6): print(x)
x=('Hello ')
x*4
To convert a list or a dictionary into a tuple, use tuple() function.
x={4,9,12}
y=tuple(x)
y
A dictionary is a key-value pair unordered set. Dictionary is denoted by curly bracket {}.
x={'fruit':'apple', 'color':'red', 'taste': 'sweet'}
x
Access and alter the value of a dictionary by the key
x['color']='green'
'the ' + x['color'] + ' ' + x['fruit'] + ' is ' + x['taste']
Use pop() method to return the value, given the key.
x={'fruit':'apple', 'color':'red', 'taste': 'sweet', 'shape':'round'}
x.pop('fruit')
To change the key, we can utilize the pop method: mydict[new_key] = mydict.pop(old_key)
x={'fruit':'apple', 'color':'red', 'taste': 'sweet'}
x['colour']=x.pop('color')
x
The key in a dictionary must be unique, otherwise the later key will replace earlier key
x={'fruit':'apple', 'fruit':'banana', 'taste': 'sweet'}
x
The value can be repeated, as long as it is for different key. Order does not matter.
x={'fruit':'apple', 'color':'sweet', 'taste': 'sweet'}
x
The keys() method will return tuple of keys in a dictionary. Remember tuple is immutable.
x={'fruit':'apple', 'color':'red', 'taste': 'sweet'}
for k in x.keys():
print(k)
The values() method will return tuple of values in a dictionary.
for v in x.values():
print(v)
The items() method will return tuple of key and value in a dictionary.
for i in x.items():
print(i)
We can separate the key and the value from item.
for k,v in x.items():
print(k,': ', v)
Use in and not in operators to check whether a certain key or value exist in a dictionary.
'apple' in x.values()
'color' not in x.keys()
To remove one item in dictionary, use del.
x={'fruit':'apple', 'color':'red', 'taste': 'sweet', 'shape':'round'}
del x['taste']
x
To remove all items in a dictionary, use clear() method.
x={'fruit':'apple', 'color':'red', 'taste': 'sweet', 'shape':'round'}
x.clear()
x
To delete the dictionary variable, use del.
x={'fruit':'apple', 'color':'red', 'taste': 'sweet', 'shape':'round'}
del x
To convert from key-value pair of tuple sequence ino a dictionary use dict() function.
y=[('fruit','apple'), ('color','red'),('taste', 'sweet')]
x=dict(y)
x
To create a dictionary from two arrays of keys and values, use zip() function.
keys=['fruit', 'color', 'taste', 'shape']
values=['apple','red', 'sweet','round']
x=list(zip(keys,values))
print(x)
y=dict(x)
y
To build dictionary from a range, use iterator
{y: y%3 for y in range(1,15,2)}
In general, a dictionary is unordered sequence, thus it cannot be sorted. To sort a dictionary by key or by value, you need to use OrderedDict.
import collections
y={'color': 'red', 'fruit': 'apple', 'shape': 'round', 'taste': 'sweet'}
od = collections.OrderedDict(sorted(y.items()))
od # sorted by key
od = collections.OrderedDict(sorted(y.items(), key=lambda k: k[1], reverse=True))
od # sorted by value
Using function sorted() will return a sorted list of the keys
y={'color': 'red', 'fruit': 'apple', 'shape': 'round', 'taste': 'sweet'}
sorted(y)
To sort the values and return a list, we can use function sorted() with argument of the dictionary values.
sorted(y.values())
A set is an unordered collection with no duplicate itemss. A set is a dictionary without key. Set operations are
y={3, 4, 8, 12, 8, 2, 3, 4, 12, 3, 4}
y # set gives unique values
x={'apple', 'banana', 'cherry', 'durian','kiwi'}
y={'durian','kiwi' ,'mango', 'orange','pineaple'}
x|y # set union
x&y # set intersection
x-y # set difference
x^y # set symmetric difference
y-x # set difference
x={2}
y={5}
print(str(x) + "&" + str(y) + "=", x&y) # set intersection
print(str(x) + "|" + str(y) + "=", x|y) # set union
print(str(x) + "^" + str(y) + "=", x^y) # set symmetric difference
Distinguish set operation from bitwise operation
x, y = 2, 5
print(str(x) + "&" + str(y) + "=", x&y) # bitwise and
print(str(x) + "|" + str(y) + "=", x|y) # bitwise or
print(str(x) + "^" + str(y) + "=", x^y) # bitwise xor
Function is a mini program that consists of several statements and call them as single function name. Function can receive no argument or any number of arguments. Function can return a value following a keyword return. You can think a function as a blackbox that receives inputs and produces an output.
def f(a,b):
return a+b
f(2,3)
The return value is not necessarily one value. Some function receive no argument.
def f():
a=5
b=7
c=9
return a,b,c
x,y,z=f()
w=[x,y,z]
w
To make function that produces no output, simply skip the return statement. Implicitly, this function will return None object.
Documentation of the function should contain a short description of the purpose of the function and explain what the different arguments and return values are. This documentation strings are usually enclosed in triple quotes """ or ''', which allow the string to span several lines.
def h():
'''return none'''
if h() is None:
print("function h() was called")
Some arguments of the function can have a default value.
def k(a,b=3.2, c=True):
if c:
return a+b
k(5)
Variables outside the function has global scope. Variables defined inside a function has only local scope inside that function. In the example below, variable a has global scope that function g() can access it. Variable b has local scope that is available inside the function.
a=5
def g():
b=a+2
print('b = ',b,'; a = ',a)
g()
To defend your function against mistake in input, use try-except syntax
def f1(a,b,c=3):
try:
d=a+b+c
except (RuntimeError, TypeError, NameError, ValueError):
d = 0
return d
print (f1('a',2))
print (f1(2,3))
In Python, you can define functions inside a function. This will create hierarchical functions.
def f_top(a):
b="magic-" + str(a) + " "
def f_mid(b):
c=[b*2, b+"is happening"]
def f_bottom(c):
return [c , "boom!"]
return f_bottom(c)
return f_mid(b)
f_top("word")
Function can call other functions. When a function call itself, it is called recursive function. Any recursive function must have a base value.
def fibonacci(n):
if n < 2:
return n # this is base value
return fibonacci(n-2) + fibonacci(n-1) # this is the recursion
print([fibonacci(x) for x in range(1,20)])
In Python, a function can be assigned into a variable. A function without a name is called anonymous function. To make anonymous function, use lambda statement.
Syntax: varName = lambda argList : expression
h = lambda x: x**2 + 1
h(3)
The above anonymous function is equivalent to
def h(x):
return x**2 + 1
h(3)
The following anonymous function receive several arguments
affine = lambda a,x,b: a*x+b
affine(3,4,5)
function map() is useful to apply the function to all the elements of the sequence.
Syntax: iterator = map(function, sequences)
a=[3,1,3,5]
x=[4,2,5,1]
b=[5,3,4,2]
list(map(affine,a,x,b))
list(map(lambda x: x**2, range(10)))
Function map is actually the same as list comprehensions. We can also apply this technique to a list of functions instead of a list of values.
from math import sin, cos, tan, pi
def mapFunction(x,functions):
return[ func(x) for func in functions ]
functions = (sin, cos, tan)
mapFunction(pi/2,functions)
Use function eval(string) to run a string code. The simplest would be to convert string to a numerical value. However, any valid Python expression stored as text in a string can be turned into Python code and run using eval.
eval() is a function with delayed execution.
eval('12.5+13.5')
def h(x):
return x**2 + 1
eval('h(3)+h(5)')
Python is object oriented programming language. You can define a class and object. Everything in python is an object of certain type. Each data type is an object of the particular class of the data type. Each function is an object of function class.
Object is a module consist of data and functions. The data inside an object is called object property or attribute while the functions inside an object are called methods. Any object should have a blue print or a pattern that create that object. The blue print of objects of similar type is called a class.
To know the class of an object, use type() function.
a="abcd"
type(a)
To define a class simply type
class className([optional input arguments]):
To define an object, we use the following syntax:
objectName = ClassName()
To access object property use the following syntax:
varName=objectName.propertyName
To change the value of an object property:
objectName.propertyName=varName
To call object method use the following syntax:
objectName.methodName()
class MyFirstClass():
b=8 # initial class property
def myFunc1(self, a):
self.b=3 # class property change inside this method
b=5 # this is a local variable inside this function
print("argument=",a)
myObj=MyFirstClass() # defining an object of a class
print(myObj.b) # print class property
print(myObj.myFunc1(25)) # print result of class method
print(myObj.b) # class property change because we called the class method
myObj.b=13 # we alter the value of object property
print(myObj.b) # print the result of our change
To find out about what is available in an object, Python exposes everything that exists in an object when you use the dir() function.
vars() function shows the variables and the values.
print(type(myObj)) # show the clas name
print(dir(myObj)) # show all accessible properties and methods
print(vars(myObj)) # show the attribute and its value = myObj.__dict__
print(getattr(myObj,'b')) # show the value of the attribute
An object can inherit the properties and method of other objects. To set the inheritance, put the super class into argument of the class. Python allows multiple inheritance.
class className(list of superClassName) :
variable self is used to refer to the current object.
Observe the Car and Bus classes override the superclass attribute.
class Vehicle(): # this is the superclass
wheels=0
def __init__(self, name): # constructor is called when the object is initiated
self.name = name + " vehicle"
class Car(Vehicle): # this class inherit Vehicle
def __init__(self, name): # constructor is called when the object is initiated
self.name=name
self.wheels=4
class Bus(Vehicle): # this class inherit Vehicle
def __init__(self, name): # constructor is called when the object is initiated
super().__init__(name) # call the superclass method
self.wheels=6 # overide the superclass property
myCar = Car("Toyota")
print(myCar.name) # observe there is no "vehicle" here
print(myCar.wheels)
myBus = Bus("Ford")
print(myBus.name)
print(myBus.wheels)
myVehicle=Vehicle("Proton")
print(myVehicle.name)
print(myVehicle.wheels)
Polymorphism means many forms. The function below can receive many different types of object as long as the object has wheels property.
def CountWheels(name,myVeh):
print(name, " has ", myVeh.wheels, " wheels")
CountWheels("BMW",myCar)
CountWheels("GM",myBus)
CountWheels("Mazda",myVehicle)
Date and Time are object in Python. We need to import the module first
import datetime
t = datetime.time(1, 2, 3)
print(t)
print('hour :', t.hour)
print('minute:', t.minute)
print('second:', t.second)
print('microsecond:', t.microsecond)
print('tzinfo:', t.tzinfo)
t1 = datetime.date.today()
print(t1)
print('ctime:', t1.ctime())
print( 'tuple:', t1.timetuple())
print( 'ordinal:', t1.toordinal())
print( 'Year:', t1.year)
print( 'Mon :', t1.month)
print( 'Day :', t1.day)
print( "Current date and time: " , datetime.datetime.now().strftime("%c")) # localized representation
print( "Format as you wish: " ,datetime.datetime.now().strftime("let's meet on %d/%B, %y at %H:%M:%S"))
print( "Current year: ", datetime.date.today().strftime("%Y"))
print( "Month of year: ", datetime.date.today().strftime("%m"))
print( "Day of the month : ", datetime.date.today().strftime("%d"))
print( "Day of week: ", datetime.date.today().strftime("%A"))
print( "Weekday of the week: ", datetime.date.today().strftime("%w"))
print( "Week number of the year: ", datetime.date.today().strftime("%W"))
print( "Day of year: ", datetime.date.today().strftime("%j"))
d1 = datetime.date(2018, 12, 31)
print('d1:', d1.strftime("%a"))
d2=datetime.datetime(2019, 12, 31, 23, 55, 25)
print(d2.strftime("%A %d %b %Y %H:%M:%S"))
Use Try and except Exception as err to deal with error.
def dayInWeek(row):
try:
d1 = datetime.date(row['Year'], row['Month'], row['Date'])
return d1.strftime("%a")
except Exception as err:
return math.nan
data=[{'Year': 2016, 'Month': 2, 'Date': 29},
{'Year': 2018, 'Month': 12, 'Date': 30},
{'Year': 2019, 'Month': 0, 'Date': 30},
{'Year': 2017, 'Month': 9, 'Date': 2}]
list(map(lambda row: dayInWeek(row), data))
last update: Sept 2017
Cite this tutorial as: Teknomo.K. (2017) Brief Introduction to Python http://people.revoledu.com/kardi/tutorial/Python/
See Also: Python for Data Science
Visit www.Revoledu.com for more tutorials in Data Science
Copyright © 2017 Kardi Teknomo
Permission is granted to share this notebook as long as the copyright notice is intact.