Stop Using Excel for Data Analytics: Upgrade to Python | by Tyler Folkman | Towards Data Science

In 2017, it was estimated that 750 million people worldwide used Excel. The population of the world in 2017 was about 7.6 billion. That means roughly 10% of the population was using Excel and I would guess mostly for data analytics. That is insane.
There is no doubt that Excel has been an incredibly important tool for companies and still has a place in the toolkit of every data analyst and scientist, but for most of your work, you need to stop using Excel and upgrade to Python. I’m going to show you why.
So, if you still have not taken the leap to learn Python and take your data analytics and visualization skills to the next level, I present you with 5 reasons why you need to learn Python right now. By the end, I’m confident you’ll be looking forward to replacing most of your Excel work with Python.
Excel is great when you want to do quick, ad-hoc analysis with small data, but once you want to move to a larger scale, it just doesn’t work. Excel can support data up to 1,048,576 rows by 16,384 columns. On the other hand, Python can scale to the size of your memory and also has many tools that support out-of-memory computations.
For example, the Dask library allows you to scale your computations to run on a cluster of machines and not just your laptop. In fact, if you are familiar with Pandas, it’s almost exactly the same code to read in a CSV:
import dask.dataframe as dd # Load the data with Dask instead of Pandas. df = dd.read_csv(<file_path>)
One line of code and you are now reading in data larger than your computer’s memory. I’d show you how to do that in Excel, but it’s not even possible.
If this code looks foreign, check out this course that teaches you everything you need to know to get started with Pandas.
Also, Python can scale when it comes to multiple data sources. While Excel is both the data store and the computation engine, Python is completely data agnostic. If you can find a way to read your data into Python, you can use it. And since Python has so many great libraries, it is trivial to read in data from many sources such as CSV, Excel, JSON, and SQL databases.
Lastly, Python is an amazing programming language when it comes to automation. Since you can connect Python directly to any data source, it is easy to schedule a job that will re-pull your data with any updates, run your calculations, and even create a report or dynamic dashboard saving you tons of time. Excel, on the other hand, requires far too much manual labor and cannot automate updates.
Reproducibility is the concept that any analytics or visualizations you create should be easy and straightforward to reproduce for someone else. Not only does someone need to be able to re-run your process and end up with the same result, but they should also be able to walk through your steps to ensure accuracy. This concept is extremely important as you start relying on automation. Automation is amazing when working correctly, but when incorrect, automated reports can be a nightmare.
Reproducibility with Excel is very challenging. Excel calculations in cells are all but impossible to check at any type of scale. Data types are extremely confusing because what you see isn’t always what is represented in the raw data, and while VBA makes reproducibility slightly better, at that point, you’re much better off investing in learning Python.
Take a look at this Excel document:
You know the sum column should be the sum of a and b, but how do you confirm that? You could check one of the formulas and see that it is in fact the sum, but since every cell can be its own formula, what if they all are not correct? If you were not paying attention, you might have missed that row x was wrong.
But in Python, your sum would look like this:
a = [1,2,3,4]b = [5,6,7,8]sum = []for i in range(a):    sum.append(a[i] + b[i])
This code is clear and easy to confirm that the sum is always calculated correctly.
With Python, you get all the tools developed to make reproducibility and collaboration better for software engineers. On top of that, Python is superior for data connectivity, allowing us to analyze data in the cloud and repeat a process instantly. Git, unit testing, documentation, and code formatting standards are all prevalent in the Python community. With Python 3, you can even add static typing to make your code even more clear. All of these tools make it easier to ensure your code is written well and correctly. So that the next time you look at your code or someone else picks it up, it’s easy to reproduce and understand.
If you know Excel, you know Excel. While the skills you learn are useful, they are not transferable to anything else. One of the things I like most about Python is that not only is it an amazing tool for data analytics and visualization, but it’s a solid programming language that can be used for so many other things.
Want to do machine learning or even deep learning? You can do that with Python. Want to build a website? Python can do that. Want to automate your smart home? Python can do that as well.
Also, Python is much closer to other programming languages than Excel. That makes it much easier to pick up other languages you might encounter along the way. Learning Python opens up far more doors than Excel ever could.
Lastly, the demand for Python is incredibly high. According to StackOverflow, in 2019, it was ranked as the world’s 4th most popular programming language among professional software developers as well as the first most wanted programming language. And Indeed says the average Python developer salary in the US in 2020 is $120K per year. Not bad.
Excel has a lot of built-in formulas, but it pales in comparison with Python’s capabilities. Not only does Python offer hundreds of libraries to make advanced statistics and analytics easier, but it can also take your visualizations to another level. With tools like Matplotlib, Plotly, Streamlit, and Seaborn, you can create beautiful visualizations of data as well as interactive dashboards and plots.
Numpy and scipy have amazing support for scientific computations, linear algebra, and vectorized calculations. And scikit-learn lets you train machine learning algorithms from decision trees to gradient boosting machines. I think xkcd said it best:
Given all the amazing benefits of Python over Excel, it must be hard to learn, right? No! Check out the Java version of Hello World, the simplest program:
class HelloWorld {    public static void main( String args[] ) {        System.out.println( "Hello World!" );    }}
Python is literally one line: print(“Hello World!”). It doesn’t get any simpler. Python is one of the easiest programming languages to pick up and has one of the most active communities, especially in the data analytics world. Python is one of the most intuitive programming languages out there, and it’s even understandable for someone with little background in computer science! While the learning curve Excel might seem preferable, there is far less payoff on the other end. Python’s learning curve is worth the time and effort in a way that Excel will never match due to its one-size-fits-all design.
Python is easy to use, and with a huge community of support, it’s never been easier to learn.
To show you just how easy Python is, in the next section I will introduce you to some of the foundations for data analytics and visualizations in Python.
To get you started, I want to walk you through some basic commands and operations in Python that will be essential to your data analysis skills. Let’s start with the foundations.
The first thing you will notice is that Python makes use of whitespace and does not use a use semicolon ; like other languages. Here is a very simple example:
x = 5y = 10print(x+y)
We will make use of many libraries, some that are pre-installed with Python and some we will have to install ourselves. To get a library use an import statement:
from collections import Counter
This command imports the class Counter from the collections library. Counter is a very useful tool for data scientists; it can count the number of times items appear in collections such as lists. For example, in the code below we will create a list of marriage ages. Using Counter we can quickly count the number of times each unique age appears.
Lists are a useful data structure to store data. They will be studied in more detail during the next lesson. For example:
from collections import Countermarriage_ages = [22, 22, 25, 25, 30, 24, 26, 24, 35]value_counts = Counter(marriage_ages)print(value_counts.most_common())
You can see that we created a list containing marriage ages using the [] at line 2. We then fed that list into the Counter function at line 4 to print out the most common values as a list of tuples, at line 5.
A tuple is a collection inside the (). These tuples contain two elements: the value and then the number of times that value appeared in your list. The frequency orders the list of tuples. The value with the most occurrence appears first.
Functions are also useful. Functions in Python start with the keyword def and the function name followed by the inputs the function expects within brackets. Here is a function that takes in 2 inputs, x and y, and returns the sum:
def add_two_numbers(x, y):  # function header    """    Takes in two numbers and returns the sum    parameters    x : str        first number    y : str        second number    returns        x+y    """    z = x + y    return z  # function returnprint(add_two_numbers(100,5))  # function  call
Functions can also be anonymous, meaning that you don’t have to declare them with the above structure. Instead, you can use the lambda keyword. Here is the same function as above, but as an anonymous function:
y = lambda x, y: x + yprint(y(100,5))  # call the function
It’s time to make the switch to Python. There are no more excuses! I hope this post helped you see the benefits of learning Python and break down some of the barriers to learning.
Go and take your skills to the next level with Python!