How To Check If Cell Is Empty (Or Not): Google Sheets

How do you check if a cell is empty or blank in Google Sheets? There is a handy function called ISBLANK which enables you to check if a cell is empty. What Does Empty Really Mean? In Google Sheets there are two ways of having an empty cell, one way is by defining an empty string "" and another way is by having nothing in that cell. To check that a cell meets these criteria of being “empty” we use the ISBLANK function, like so: ...

September 12, 2021 · 4 min · 666 words · Ryan Sheehy

What Is The Formula To Calculate Age?

Recently, I had an issue where I needed to calculate the age of a person at specific dates throughout the year. Using a Google Sheet, I thought I could simply subtract one date from the other and divide by 365, but this ended up not being as accurate as I wanted. To calculate somebody’s age at a specific point in time you need their birth date and a comparison date to calculate the age of the person by. Start by subtracting the years from each other, and then if the month and day of the comparison date are before their birth month and date, then subtract one. ...

August 26, 2021 · 4 min · 721 words · Ryan Sheehy

How To Flatten A List Of Lists In Python (Examples & No Imports)

Recently, I had an exercise where I needed to flatten a two-dimensional list down to just one dimension, something where I needed the result to be like this: [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] = > [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] There were a couple of ways I completed this task, one involved using the common for-loop process but as a one-liner, another involved using a standard Python function, and the third way introduced me to the concept of recursion in Python. ...

August 23, 2021 · 15 min · 3040 words · Ryan Sheehy

Is A List A Data Type?

In Python there is a handy function to determine the data type of any variable, and it is aptly called type(). This function can help to assess whether a variable is of a certain data type to help you perform any type of computation on it. The different data types available in Python are: int, float, str, dict, list, and tuple. Therefore, list is a data type and can be checked using the type() function. ...

August 23, 2021 · 3 min · 508 words · Ryan Sheehy

Google Sheets Count If Not Blank: Best Approach

How do you count a range of cells and exclude counting empty or blank ones in Google Sheets? The easiest approach to count cells that are not blank is to use the COUNTA() function. The COUNTA() function has the following parameters: = C O U N T A ( v a l u e 1 , [ v a l u e 2 . . . ] ) The COUNTA() Google Sheets function takes one or more values and counts those values that do NOT have any content. However, just because a cell may look like it doesn’t contain content it may still be added to the count. ...

August 2, 2021 · 6 min · 1073 words · Ryan Sheehy

Python For Loop One Liner With IF Conditions [Code Examples]

There have been times when I wanted to perform a simple for-loop filter operation on a list, and I’ve often wondered if there’s a quick and simple way to do this without having to import any libraries. What I discovered is that there was an easy way, and what’s awesome about it is that it can be done in one simple line! If you’ve been operating with dictionaries or lists, you would have likely come across a need to loop through each key or element within those structures to only obtain a certain set of data from it, or to obtain a new modified set of data from the original structure. ...

July 30, 2021 · 6 min · 1236 words · Ryan Sheehy

Python: Get Average Of Two Dimensional List - No Imports [Code Examples]

In my previous article where I found the average of a list in Python without using imports, in this article I want to expand how you could apply the same concept, but to two-dimensional lists. Thankfully, if you know how to find the average of a one dimensional list in Python, you can simply expand this knowledge to finding the average of a two-dimensional list. The big question to ask, when finding the average of a two-dimensional list, is seeking what is it that you want to average: is the whole list, or just an average of each row, or is it an average of each list? ...

July 29, 2021 · 6 min · 1243 words · Ryan Sheehy

How To Sort 2D Array In Python: 1 Line Of Code Without Numpy

How do you sort a two-dimensional array in Python easily without importing libraries? Thankfully, some native functions in Python make sorting arrays a breeze. I recently had a project where I had the following data structures, representing each unpaid invoice by the customer, the days they were overdue and how much was outstanding. Here’s a simplified sample of the data I was working with (the first row contains the name of the columns of the array): ...

July 29, 2021 · 7 min · 1399 words · Ryan Sheehy

Python: Average Of List Of Numbers - Without Imports [One-Liner]

How do you calculate the simple average of a list of numbers in Python, without needing to import any libraries? Unfortunately, there’s no native average or avg function in Python to easily calculate the average of a list containing just numbers: 1 2 3 4 5 example_list = [1, 2, 3, 4, 5, 6] average(example_list) # NameError: name 'average' is not defined avg(example_list) # NameError: name 'avg' is not defined To calculate the average of a list of numbers in Python, use the sum function and the len function and divide the total sum by the total length of the list to obtain the average, like so: ...

July 20, 2021 · 3 min · 619 words · Ryan Sheehy

Check For Word In String: Python 1 Liner

How can you check if a word is found in a string using Python? Recently, I had an issue where I wanted to exclude strings from a list if they contained a certain word. I thought I could use the following common code familiar to most using Python: i f # ' w d o o r d s ' o m i e n t h ' i h n o g w t o f i n d w o r d i n s t r i n g ' : But the problem ended up being a little more difficult than that. For example, what if you want to exclude the term word but not if that word is found inside other words, like sword? ...

July 14, 2021 · 6 min · 1217 words · Ryan Sheehy