top of page


1. Introduction.
1.1. Introduction
1.2. Installing Anaconda Navigator
1.3. Alternative: install python & VS Code
1.4. Comments in our code
1.5. Case sensitivity
1.6. Print statements on a single line
2. Interacting with data from external sources 2.1. Introduction 2.2. How to effectively read an .xlsx file
2.3. Skip reading rows when reading a dataframe
2.4. How to read a specific sheet from an Excel file
2.5. Set the index of a dataframe upon reading
2.6. Read specific columns from an Excel file (usecols)
2.7. How to read data from World Bank's database
2.8. Send many dataframes into the same Excel
2.9. How to send a dataframe to a CSV file
2.10. How to hide warnings and how to trigger warnings manually
2.11. Read rows from the top/bottom (nrows, skipfooter)
2.12. How to check if an Excel cell is empty
2.13. Check the version of the installed packages
2.14. How to hide special warnings
2.15. How to read a .txt file
2.16. How to remove white spaces from a file (strip,replace)
2.17. Read a txt file using readlines
2.18. Write to a text file
2.19. Append to a text file
2.20. Open a text file as r+
2.21. Read the first 3 rows of a file (enumerate)
2.22. Read the first 13 characters of a file
3. Important operations with the dataframe index
3.1. How to set and reset the index (reset_index, set_index)
3.2. Change the name of the index of a dataframe
3.3. Find the row/column index of any element of a dataframe
3.4. Command enumerate() to enumerate rows/elements.
3.5. Sort the index of a dataframe, sort_index 4. Important List operations 4.1. Introduction 4.2. How to sort the elements of a list, sort, sorted
4.3. How to sort using lambda & functions
4.4. How to remove some elements from a list
4.5. How to create a sublist from another list
4.6. How to print first and last elements of a list
4.7. Place in a list the elements of another (extend / append)
4.7b. Extending a list with the elements of another list
4.8. How to remove all occurrences of an element
4.9. Difference between pop() and remove()
4.10. List comprehension
4.11. Slicing
4.12. Enumerate, index
4.13. series.isin(list)
4.14. Count how many times an element is in a list (count)
4.14b. Check if an object is part of a list (2 ways: in, count)
4.15. Make a copy & an alias of a list
4.16. List concatenation (lst1+lst2)
4.17. Repeat the elements of a list (list*c)
4.18. Iterating in a nested list
4.19. Convert a list of lists, into a list with their elements 5. Important Dataframe Operations:
1. Introduction
2. How to return elements from a dataframe
3. How to delete rows/columns from a dataframe
4. How to read the row /column index and values of a dataframe
5. How to show the max number of rows and columns of a dataframe
6. How to create a copy of a dataframe
7. How to correctly take a backup of a dataframe
8. How to change specific values of a dataframe while leaving the rest unchanged
9. Create a new column and populate with elements of another column
10. How to change the order of the columns of a dataframe
11. How to create a new row in a dataframe and fill it with values from other rows
12. How to fill a new column with values 1,2,3,... ,
13. How to use Pivot tables
14. How to rename rows and columns of a dataframe
15. How to create a dataframe using a dictionary
16. How to find the transpose of a dataframe
17. Selecting rows and columns from a dataframe
18. Copy-paste a row of a dataframe via np.repeat
19. How to sort the columns of a dataframe
20. How to change the data type of a column / row of a dataframe
21. How to select many rows via loc, arrange
22. How to delete many rows from a dataframe at once
23. How to return the value under other columns, in the same row of a dataframe
24. How to Iterate through the rows of a dataframe
25. How to sort the values of a column
26. How to populate a column using list, arrays, Series
27. Define a dataframe with and without a dictionary
28. Define a dataframe using list comprehension 29. find the max, min, mean value of columns of df
30. sum any part of df
31. sum two dataframes
32. sum under specific columns
33. new longer equivalent df slash slash
34. groupby min max mean over rows
35. using groupby with slash slash
36. select specific rows using loc arange 6. How to effectively use the command "Apply": 1. Introduction 2. Format the values of a dataframe to percentages
3. Format the values of a dataframe to show 1 decimal point
4. Apply a function to every element of a series/ dataframe 7. Effective operations with Loops 1. Introduction 2. Prevent copying rows from a dataframe to a dictionary
3. How to not allow duplicate values while inserting a new row
4. Avoid duplicate entries using while and break
5. Using continue, break, pass
6. Using for-else
7. Using while for equivalence
8. Using while True
9. Using while else
10. Typical syntax of a for loop
11. Syntax of a for loop with lists (enumerate, range)
12. Syntax of a for loop with tuples (enumerate, range)
13. Syntax of a for loop with strings (enumerate, range)
14. Nested for loops
8. Multi-level (column) dataframes:
1. Introduction
2. How to define a dataframe whose column index has many levels , headers
3. How to rename a column
4. How to remove a level
5. Compressing all levels into 1 Excel cell or showing them as is.
6. How to print dataframe merged cells as unmerged in Excel
7. How to iterate through the rows of a multi level dataframe 9. Important operations with Conditionals: 1. Introduction 2. Command if- elif
3. Inline if statement
4. Print statement with if-else embedded 10. Effectively using Logical operators 1. Introduction 2. How to correctly write AND OR TRUE FALSE
3. How to correctly write the NOT operator
4. The De Morgan's Law. AND, OR, NOT, statements
5. Comparing objects of type int, str, float, bool with each other
5b. Truth Tables
6. Type conversions: Int, Float, Str, Bool
7. Combining NOT with empty lists and strings
8. what it means for x to be none, empty list, empty string
9. Difference between 'is' and '='
11. Effective operations with Tuples:
1. Introduction
2. How to iterate through tuples. Different types of for-loops
3. How to concatenate 2 tuples
4. Defining a tuple
5. Tuple comprehension
6. Sorting a tuple
7. Enumerating a tuple.
8. Find the frequency of elements in a tuple.
9. Tuple immutability
10. Tupple element repetition (t1*c)
11. Slicing 12. Dealing with NaN values effectively: 1. Remove NaN values by deleting rows or columns.
2. Find if a dataframe has at least 1 missing value. And find their exact location
3. Using min_count to sum if there are NaN values
4. Manually place NaN values to dataframes
5. Sum rows of a dataframe by ignoring NaN
6. Replace missing values with 0
13. Python Implementation of Excel Functions
1. Introduction
2. Model the Vlookup Excel function in Python
3. Model the SUMIFS function in Python (
4. Model the AVERAGEIFS function in Python
14. Effective operations with Strings:
1. Introduction (38 sec)
2. How to evaluate string expressions using eval ()
3. Removing characters from end, start of a string
4. How to break a long sequence of characters in sets of characters
5. How to select part of a string e.g. all strings except last 3 characters
6. Use replace() to remove white spaces from a string
7. Find multiple occurrences of a subtext in a long string
8. Selecting specific characters from a column using "str"
9. How to replace the text of a string using replace()
10. Join strings from inside a list
11. multiline strings
12. Formatting strings and f-strings
13. Count how many times a character is in a string
14. in, find() with strings
14b. Check if an object is part of a list (2 ways: in, count)
15. Right justify text
16. Check if a string contains only an integer (isdigit)
17. Lowering the string (lower)
18. Splitting a string into a list of strings (split)
19. Printing special characters (\')
20. Multiplying a string with a number
21. Deleting characters from a string
15. Creating variables : 1. Introduction 2. How to define variables using globals()
3. Multiple assignment
4. Underscore variable 16. Sets: 1. Introduction
2. Definition of a set 3. Define a set, add/remove elements
4. Convert a list string to a set
5. Difference of two sets. Symmetric difference. Difference update
6. Set comprehension
7. Subset, superset, proper subset
8. Intersection & union of two sets
9. Checking for duplicates using sets
17. How to effectively use Series:
1. Introduction
2. Editing strings inside series
3. How to define a series object that has a constant value
4. Selecting a column as a Series object versus as a Dataframe
5. Storing an array to a dataframe and broadcasting 18. Important operations with Numpy arrays: 1. Introduction 2. How to effectively concatenate arrays
3. How to create equally spaced numbers
4. Reshaping the arrays
5. 1D 2D 3D arrays from lists
6. How to modify elements of an array
7. How to use arange to create 1D and 2D arrays
8. eye ones zeros. Instantly make arrays of constants
9. Flattening an array ie collapsing it to 1D 19. Important Function implementations: 1. Introduction 2. Docstring
3. Count how many times a function is called
4. How to return many values from a function
5. Default values for parameters
6. A function calling another function
7. Many return statements
8. Functions passed as input
9. Nested functions
20. args kwargs:
1. asterisk iterable
2. args kwargs
3. More examples 21. Date objects: 1. How to update a value in a DateTime index in a dataframe
2. Using the Workalendar package for country-specific Dates
3. Use timedelta() for time conversions 22. Datatypes: 1. Introduction (52 sec) 2. Use __name__ to find the datatype of an object
2b. Another example with __name__
3. How to check if the datatype of a variable is: int, float, str, NaN, Nonetype
4. Datatype of every element of a dataframe: for loop, dtypes, astype()
5. Converting the datatype of the elements of a column. 23. Dictionary: 1. Introduction
1b Define a dictionary in 3 ways. Print its keys, items 2. Define a dictionary and loop through it
3. How to find the number of elements in a dictionary
4 Convert a dictionary into a list/set of keys/values. Find its unique values
5. How to convert a dataframe to a dictionary and how to use it
6. How to print the first 6 elements of a dictionary
7. What it means to check if x is in dictionary
8. How to convert a single value into a dictionary so that all keys have the same value
9. How to avoid errors when a key is not found in a dictionary. Command: get
10. How to unite two dictionaries.
11. Dictionary comprehension
12. Delete a key from a dictionary
13. Sort a dictionary
14. Mutability of a dictionary
15. Practical use of a dictionary
16. dict, sets have bettee performance than lists 24. Special types of dictionaries: 1. Default dictionary: how it works and why to use it 25. Important mathematical operations: 1. Trigonometry, infinite and pi
2. regular/integer/modulo division // %
3. dot product of two arrays np dot 26. Errors (Exceptions): 1. Try-except block
2. The "finally" statement
3. Raise own errors based on user input 4. How to raise our own errors
5. Unhashable type error
6. While loop with try-except 27. Random package: 1. random choice
2. randint
3. randrange
4. random.random, random.seed
5. random.sample ,: sample without replacement
6. function for fixing random seeds 28. Lambda function 1. Lambda
29. Map and filter
1. Map
2. Filter
30. Modules and files:
1. Import statement
2. from import, statement
3. how to avoid circular imports
4. if name main
31. Packages:
1. Create a package and import
2. Running from main, or package
3. import a module function in main
4. import modules using relative imports 5. packages inside packages
6 name conflicts with built-in packages
32. Conclusions:
1. conclusions
bottom of page