How to Apply a Function to List Elements

Problem Formulation and Solution Overview As a Pythonista, coding issues may occur where you need to apply a function against array/matrix elements. To make it more fun, we have the following running scenario: The organization Happy Mortgages has six (6) different Mortgage Terms available: 30-Year, 20-Year, 15-Year, 10-Year, 7-Year, and 5-Year terms. The US Federal … Read more

Is There A Way To Create Multiline Comments In Python?

Summary: You can use consecutive single-line comments (using # character) to create a block of comments (multiline comments) in Python. Another way is to use “”” quotes to enclose the comment block. Problem Statement: How to create multiline comments in Python? Other programming languages like C++, Java, and JavaScript, have an inbuilt mechanism (block comment … Read more

How to Apply a Function to Series Elements

Problem Formulation and Solution Overview As a Python Coder, situations arise where you will need to apply a function against elements of a Series. To make it more fun, we have the following running scenario: Rivers Clothing does business with six (6) different countries. The Tax Rates for the associated countries have increased by 2%. … Read more

How to Apply a Function to Column Elements

Problem Formulation and Solution Overview As a Python Coder, situations arise where you will need to apply a function against elements of a DataFrame Column. To make it more fun, we have the following running scenario: You have a DataFrame containing user information (including the column Recurring). This column is the Monthly Fee for a … Read more

Define A Method Outside Of The Class Definition

[toc] Problem Statement: How to define a method outside of class definition in Python? Example: Can we create foo() outside of the class definition or maybe even in another module? Introduction We all know Python is an object-oriented programming language, and in Python, everything is an object including properties and methods. In Python, the class … Read more

How to Delete an Object From a List in Python? 5 Ways

A Python list is a collection of objects that are indexed, ordered, and mutable. There are several different ways to delete a list item. We’ll first look at how we can delete single items from a list. And then finish with removing multiple objects. Method 1 – remove() Python list.remove() is a built-in list method … Read more

Choose A File Starting With A Given String

Overview Problem: How to choose a file starting with a given string? Example: Consider that we have a directory with files as shown below. How will you select the files starting with “001_Jan“? Python Modules Cheat Sheet To Choose A File Starting With A Given String Choosing a file starting with a given string is … Read more

Every Pro Coder Must Know These 6 Technologies to Earn More $$$

What are the most important skills you can have as a freelance developer? You may ask this question because you need to know where to focus and concentrate your learning effort. While I focus on the most important technologies in this article, I believe that the ultimate driver of your success is your knowledge of … Read more

Python Regex – ¿Cómo contar el número de coincidencias?

Para contar un patrón de expresión regular varias veces en una cadena dada, usa el método len(re.findall(pattern, string)) que devuelve el número de subcadenas coincidentes o len([*re.finditer(pattern, text)]) que desempaqueta todas las subcadenas coincidentes en una lista y también devuelve la longitud de la misma. Hace unas horas, escribí una expresión regular en Python que … Read more