How to Create a DataFrame in Pandas?

In Python’s pandas module, DataFrames are two-dimensional data objects. You can think of them as tables with rows and columns that contain data. This article provides an overview of the most common ways to instantiate DataFrames. πŸ’‘ Note: We follow the convention to rename the pandas import to pd. Create a DataFrame From a CSV … Read more

A Simple Recommendation System Using Pandas corrwith() Method

What is a Recommendation System? If you use Netflix or Amazon you have already seen the results of recommendation systems – movie or item recommendations that fit your taste or needs. So, at its core a recommendation system is a statistical algorithm that computes similarities based on previous choices or features and recommends users which … Read more

The Ultimate Guide To Python Tuples

Python has several built-in data structures such as Lists, Sets and Dictionaries (check out the articles!).In this article, you’ll learn everything you need to know about tuples including real world examples. A Python tuple is an immutable, ordered, and iterable container data structure that can hold arbitrary and heterogeneous immutable data elements. Tuple Motivating Example … Read more

Python Freelancing: My First Fiverr Gig and How I Solved It

Basic Webscraping Script in Python | Requests | BeautifulSoup | ArgParse Sold Gig ($35) This is the gig description I offered on my profile to get my first gig: An email marketing company hired me to write a Python script that satisfies the following requirements. Requirements What is the input? (file, file type, email, text,…) … Read more

How to Get Specific Elements From a List? – Most Pythonic Way!

Quick Article Summary to get a specific element from a list: Get elements by index use the operator [] with the element’s index use the list’s method pop(index) use slicing lst[start:stop:step] to get several elements at once use the function itemgetter() from the operator module Get elements by condition use the filter() function use a … Read more

The Most Pythonic Way to Remove Multiple Items From a List

Python’s built-in list data structure has many powerful methods any advanced Python programmer must be familiar with. However, some operations on lists can’t be performed simply by calling the right method. You can add a single item to a list using the method append(item) on the list. If you want to add a list of … Read more

Python 3.8 Walrus Operator (Assignment Expression)

The release of Python 3.8 came with an exciting new feature: the Walrus Operator. It’s an assignment expression, or in simpler terms an assignment inside an expression. Let’s dive into practice immediately and look at the following code: We have a list of users whose data is represented in a dictionary. We want to count … Read more

List to Dict — Convert a List Into a Dictionary in Python

That’s a very common question and the answer is: It depends.It depends on the data in the list and how you want it to be represented in the dictionary. In this article we go over six different ways of converting a list to a dictionary. You can also watch my advanced one-liner video where we … Read more