Intro to Python in Power BI

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- Yooo! What's up? This is Patrick from Guy in a Cube and in this video, I'm gonna do a quick introduction to using Python in Power BI, stay tuned. (upbeat music) If you find this for the very first time be sure to hit that subscribe button, to stay up to date from all the videos from both Adam and this guy. Okay. Python, Patrick, why are you talking about Python? You guys never talk about anything like that except when Ryan Wade came on and did a video on R, which is a cool video. If you haven't watched it you should go check that video out but in this video, I want to talk about Python. I had to build a demo of Python integrated in power BI and I decided 'why not quick make a quick video' of all the steps that I took on how to get started with this Python integration. Okay? So you guys know what I like to do instead of all this talking let's do what? Let's head over to my laptop. So the first thing you need to do is download and install Python, but I had no idea where to start but I knew I needed to get it integrated. So I went to File > Options and settings and then I chose Options, cause I remember there was a choice in the global section of the Options and so you can see right here there's R and Python scripting. So I went there and it was empty because I hadn't downloaded Python, anything like that but there was a hyperlink. So I clicked on that hyperlink and it took me here to this page. and then it said, Hey, there's a work through. So I clicked on that and thinking it brought me to the Python website and then I was looking at this, there's documentation and everything, but I clicked on downloads and you could see right here, there's a section for windows. So I click windows and then I scroll down a little bit and there's a 64 bit installer. I clicked it, download it and as I was going through the install you need to make note of where you install it the path that you installed it cause you'll need that path a little later because you'll need to install additional libraries and there is a executable like pip or something like that that you can use to install these executables. So you need to make note of that path. So after I downloaded and installed it and I closed the desktop opened it back up and then I saw everything it just automatically picked these things up and I was excited. Then I was like, okay, well I need some data but I didn't even know how to write Python, so I needed some steps. So I searched the internet and on that site that it leads you to there's some tutorials and things but I did a quick search of the internet and I landed here. I thought this was a pretty cool website that I want to share with you guys. If you go to this webpage and it'll be down in the links below this video, you'll see, there's lots of options and I just clicked one. Before I got started I remembered there's two things two ways you can use Python and Power BI. You can use it to get data and visualize data and I thought, wouldn't it be cool if I got some data and prepped some data and then I visualized it, using Python to do both. I thought that would be cool. So I noticed that there was these datasets this sns_load stuff and I said, well, let's see if I can do this in power BI. So I went over to the desktop and chose to get data and I selected more because I remembered there was a Python connector out there, right? So I typed in Python and there's my Python script and I clicked connect. I did have to tinker a little bit to figure out how to make this work, but it was pretty easy. I imported that seaborn library. It's just import and you give it an alias then you can use it. So I said, tips, that's the name of the dataset equals sns.lo and there's a method there that I can use to get some data and then you just provide the name of the dataset that you want to get. There's lots of data sets out there that you can use. Okay and I clicked, okay. I didn't think it was gonna work, but look it's a dataset cause they have sample data sets out there. Right? I checked it and I clicked transform because I wanted to see what the M looked like. So you can see there's a source, If I click on the source and see the script that I wrote and then on the navigation, it just rendered my data for me. If I go here and go to the advanced editor I can see the code that it wrapped around it, nothing too complicated and I can continue to transform this data if I wanted to but this is enough for Patrick. I was excited just to get the data in. So now it's gonna load that tip data up and I was like, okay, I want to create a visual and I decided I'd seen these swarm plots. I wanted to create something that was not already in Power BI. I know there's probably some custom visuals and things like that, but I said, Hey, let's let's be a little adventurous. Okay? So I decided I'm gonna create this swarm plot. Let me show you how I did it. So the first thing I did was I found the Python visual and I just clicked in the white space on the page and I clicked it and then I received a little prompt set. Hey, you need to enable these script visuals Sure! It's easy. Put that right there, expand this guy out and then what you need to do, any of the columns in your dataset that you're gonna use as part of your code, you need to make sure you bring them over into the value section. I was gonna use day and total bill. So I dropped that right there and I can start writing some code. So let's see, let's see if Patrick got some, some Python skills. So imports > seaborn. One thing I didn't mention, sometimes you'll need to import these libraries and remember when I said you need to remember the path where you install Python at so you will have to, you can go to a command line and like seaborn, I had to install it. So you do pip install, like we need change our directory. So if we change our directory to the location of that executable, and then if you do pip install and then if I do seaborn, it's got to go and install that package. I think it's already installed because I ran through this before, but anyway, you'll need to do that and you may possibly need to do that for other libraries and also there's a list of supported packages and so you can see there's these are the supported packages for Python and Power BI. So import seaborn, write a little Python. This is Patrick's adventure, sns. So (mumbles) and then I needed another one for my visual, matplotlib and I already imported this one, pyplot something like this, as lib and then I actually did it right? snsswarmplot(x) So what I want an X axis daily. That's what I want an x-axis and this is case sensitive, so you need to be very careful with that and then the total bill, these are the columns. So you can see the columns already there and then the dataset and this is where I got tripped up a little bit because in the documentation, they said give it the name of the dataset but in my case, I just specified dataset just like that and then I said, pit that show which is actually gonna render that, that visual for me. So now there's a little play icon, if I click play, hopefully I don't get an error Ah, let's see what I got, Let's see what I got here is seaborn there's no attributes, warm plot. So that means I spelled it wrong, right? That's okay. It's really particular but I mean, it's like any other program link you've got to specify the right things. Boom. A couple of things in the script. I need to make sure I'm paying attention to what I'm typing there but once I did that, it all works. The last thing that when you deploy this out, Python and R refreshes are only supported by the personal gateway. So if you want to use Python and are integrated into your power BI desktop, you'll definitely need to install a personal gateway on your machine. Okay. What do you guys think? Are you working with Python? Have you run into any challenges? Are you just getting started? These are some great resources to get started. I thought they were because it helped me quick quickly get started with this. If you have any questions, comments, you know what to do. Let's continue the conversation, where? In the comments below. If it's your first time visiting Guy in a Cube channel, hit that subscribe button. Like my video, big thumbs up. As always from Adam and myself. Thanks for watching, See you in the next video.
Info
Channel: Guy in a Cube
Views: 98,510
Rating: undefined out of 5
Keywords: python, python for beginners, python language, getting started with python, langage python, power bi python, power bi python data transformation, power bi python libraries, power bi python script, power bi python seaborn, power bi python tutorial, power bi python visual, machine learning, power bi
Id: 3_DOF_qjguA
Channel Id: undefined
Length: 7min 15sec (435 seconds)
Published: Wed Jun 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.