The Snake Installation
"Needs Python to run program," I wanted to avoid snake photos! PC: Programming memes

The Snake Installation

Googling the word "python" returns an interesting array (pun intended) of image results, like snake photos, code snippets, and Python language icons. While I don't like snakes, I, fortunately, don't have ophidiophobia either. This means I can easily scroll past the close-up shots of constrictor snakes to get the Python programming language graphics I want to use.

Python in Power BI

It's important to point out that while knowing Python can be helpful in using Power BI, it absolutely isn't required. In fact, I think that if you're a Power BI developer, there's far more of an impact from learning DAX than there is from learning Python. They are different languages with different uses. That's not to say that learning Python isn't useful. But rather, if you have to learn one language, DAX likely takes less time to learn (at least initially) and has a much bigger impact specifically in Power BI.

However, I still love Python. I could write code in it all day if I wanted to. I use Python for querying online data sources (APIs and zipped folders for example) to create useable data tables. I also use it to run algorithms or machine learning models quite a lot. I sometimes use it to create data visualizations. I definitely use R more often than Python though to build data visualizations, both within Power BI and in external IDEs (Spyder or RStudio for example).

No alt text provided for this image

In the Power Query Editor

In one of the latest videos in my Power BI Weekly serial course, I illustrate how to use Python to create a new query in Power Query by initially choosing the Python script data connection option. While this example initially looks like a single process script, it really breaks down into four steps.

  1. Connect to the data source.
  2. Run a Python function (that I created) on it to get the temperatures for each location.
  3. Aggregate the temperatures into a daily average for several locations in the Los Angeles area.
  4. Finally, run an anomaly detection algorithm on the data to determine which of these days represent anomalies for the daily temperatures.

No alt text provided for this image

We can also use Python to run a script on an existing query within Power Query. In an earlier video for this same serial course, I show how to push an existing data table into Python code to run as an applied step of its own in a query we already started building and transforming. Note the issue with using dates between Python and Power BI (more specifically for the M language) that I point out in this video. But don't worry! I do show one way around it within the video as well.

No alt text provided for this image

In the Visualization Pane

While I'll admit that I like the R language visual options (especially with the ggplot2 library) more than the options in Python, there are some great ways to use Python to create visuals that otherwise wouldn't be possible in Power BI. One example of this is a dendrogram. I use this tree-like heatmap visual to visualize the outcome of the hierarchical clustering algorithm in another one of my earlier Power BI Weekly videos.

No alt text provided for this image

Here's what this data visualization actually looks like in the example for this video. It's one of my favorites! There's something about the combination of the color gradient on the rectangles and the lines that show how closely related these rectangles are that makes it an especially impactful visual.

No alt text provided for this image

Supported Libraries

While the use of Python can increase our Power BI capabilities, it's also important to note its limitations. There are specific Python packages/modules/libraries that the Power BI service explicitly supports. That's not to say that others won't run when we run Python scripts in Power BI (especially for Power BI Desktop, which runs on the Python version we install on our own computer). But rather that these are the ones supported in the Power BI service when we upload our models.

No alt text provided for this image

For those wondering, I use pandas probably more than any other library, regardless of whether it's supported or not in Python (thankfully it is). I use scikit-learn (also known as sklearn) quite a bit as well to run algorithms on the data, especially once I create a useful pandas DataFrame object. For visualizations, I use matplotlib a bit, but I like the way the output appears from seaborn more. The thing is though, that seaborn is a wrapper that goes around matplotlib as well. Power BI requires us to install both the pandas and matplotlib libraries for Python to run within the application.

The options for R came out before Python within Power BI, which is perhaps why there are over 900 R libraries officially supported in the Power BI service, compared to only 8 for Python. If I were to describe my own learning process for the Python language specifically, it would look approximately like the steps below. There isn't only one way to learn skills or a language like this either. Even one single person can take many potentially different paths to learn the same skill!

No alt text provided for this image

More Algorithms

Python isn't the only programming language that I use a lot. The project at hand is the most common determinant of what tool (or tools) I use at any given point in time. But Python is one of my favorite tools to use either way!

Once I learned one programming language, it was much easier to pick up other languages because there's a lot of overlap between them both from the high-level concepts to the way of thinking about how to approach solving a problem. It's interesting how people that come from different backgrounds approach programming because what's easy for one person may be hard for someone else and there's nothing wrong with that either. Knowing how to use algorithms in Python is what makes it (and any other programming language) exciting to use. Here's a course that I love on algorithms in programming (not just Python) from fellow LinkedIn Learning instructor Joe Marini!

No alt text provided for this image

Coming Up

I'm excited to share that I'm currently working on a time series course for the LinkedIn Learning library. I'm looking forward to sharing more about this course when it comes out as well as future Power BI Weekly videos. Please subscribe to this newsletter to learn more! And keep learning! I'm always learning something new myself too!

-HW

Roger N.

Optimization Architect @ CAMS | Empowering Data-Driven Decision-Making

1 年
回复
David Ikenna Ezekiel

Data Discovery Senior Analyst @ Mars Petcare | MCT

1 年

It gets even more interesting when the user is asked to install anaconda to learn more about python. lol.

回复
Ryan Simmons

Manager, Field Support Analytics | Data Analysis | Modeling | Forecasting | Business Insights

1 年

Very cute Helen Wall

回复
Aninda Islam

@METRO | Business Intelligence | Python | SQL | PowerBI

1 年

When the user will install anaconda, they will have a snake family!

回复
David M Vermillion

The Space Data Guy ???

1 年

Imagine if that person saw a similar message for R. “It’s telling me to find a pirate to run the program.”

要查看或添加评论,请登录

社区洞察

其他会员也浏览了