Hello and welcome back to this part.
And now we have an STOL Piven and I want to show you in the next two videos a few ways how you can actually
use Python in order to create some visualizations.
Or just give you a few examples using seaborne which is a pie from a library you can use in order to
create let's say stunning visualizations because the default visualizations and plotting in Python with
met Lepp is not that good at least from from point of view.
I think so and this is a nice package in order to create nice visualizations in Python.
So what do you need to do is the first thing is you would select visualization.
In this case we want to create a python visual so you can select it and at first you need to enable
those scripts that's fine clicking a table and you can see there's a Python script and now you need
to drag fields into this valley area in order to create positions right.
But so far we can't do this because we don't have any data.
So what we need to do is we go to in this case yet they don't as always and in this case we will import
something from Excel and now I select my musket string file I selected.
You can download this from resorte section and then you simply choose the tables you want.
In this case I'm using employees orders and suppliers.
So these are the whole sheets in case you want the table.
So these have been a one to three and four.
These are the tables on these sheets.
But in this case there is no additional data so we can simply choose the sheets itself.
Okay.
And I took a note because I do not need to edit this in the very editor right now.
Click on load and just wait until the data is loaded into power.
All right.
So loading data into the model and we're done.
You can see now those tables apply here and we get our data and now we can select specific data in order
to visualize something.
In probably out with our Python Ridgewell.
So watch what I can do here is I could say I like to visualize let's say the sales and the amount.
OK I need some numerical data for that.
So I can say dragging my.
In this case at first let me select the visual again.
OK and now I need some fields and I can say I'd like to see the amount.
So direct the amount into values and then I also Grac.
In this case let's say the sales intervals.
OK.
So I could say sales and also drink them with Duvalier's and then go through these two things.
And what you can see here is what happened was the following.
So this window changed and what you can't see here is the falling the pipe and Thrope editor tells us
at first that a data frame was created this data frame in case you're familiar with Python.
This is panderers penalises library in Python which is really powerful and often used in finance.
It was actually developed for funds applications and this Pandurs package here gives us creates a data
frame for us the data frame because think of a data frame as a table which can then slice and dice and
do some kinds of filtering and all kinds of options.
OK.
So basically based on the values retractors the values area would be achieve was probably automatically
created the data frame for us so now we have a table with amount and sales.
And what also happened was duplicated rows were removed.
This happens by default.
That's also the case for the visual.
If you remember from Puddleby IMO also Class 7.
If you have taken the slots and then those that duplicate duplicate values are dropped and now we can
write simple python code in here.
OK.
And by the way just if you're wondering if you want to make any commentaries later on in your code just
to make things clearer for your audience or other people who work with your report you can use those
hash signs in order to write a commentary.
OK.
So basically what we do here is the following.
Let's say we want to create some kind of linear regression.
OK what I could do is I will import it first.
So imports in this case Metts plots Lipe my prototype dot pipe plot PI plot as T P T is simply an abbreviation
of K and the next thing is and I will also import one that was told you at the beginning.
I'd like to use seaborne which is let's say a visualization libretti on top of my prototype simply makes
all our visuals more appealing to the audience.
OK that's what I think at least as s n s s n s again is the abbreviation here.
OK.
And now what I'd like to do here is I like to also use now the symbol I reside Kensei as an s dot in
and create a linear model.
So linear regression which is l m plot in this case L and plots and all I need to do now is to find
my x value x is equal to.
And now I need to specify a max value which is sales.
OK.
And I put this in quotes.
I'm using single quotes you can also use double quotes but the sales year is the same name as appears
in the value section from all table.
OK.
That's what you have to keep in mind.
And the Y Well y is equal to and specify amount here amounts.
OK.
Also in quotes which refers to this value here.
OK.
And the last thing is I need to specify the data fring so I can say data is equal to.
In this case it's a data set.
OK.
Data sets which was automatically created by Paul VI from those two values to direct and to the values
area here.
OK so those two columns.
This is the data sets which refers to this one.
OK.
All right.
So we got this and a close my birth answers and now I simply want to plot this so I say t that show
OK.
In order to plot it to parenthesis and I can run my path into intergroup so I can simply click on the
screen button here run the script and just wait.
And here I get my visual OK.
Now you might think this looks a little bit weird.
And you're right.
And the reason for this is what we need to do when we create Python rituals is we need to tell Paul
VI that it should not aggregate the data.
OK.
So currently if you hover over values here you can see if you're right click on it that basically it's
currently the sum.
Right.
And what we want is we want this for every single entry in our data set.
So we need to tell Paul VI that it should not summarize the data.
So by default you can also see if I select the visual again when a column has some symbol here it's
summarized by default.
And this is the case or actually almost the case for numerical values.
So that's not what I want.
So I need to right click on the amounts and say don't summarize.
And also reichlich on sales and also say don't summarize.
And if we do this and wait and you can see now we got our real visuals so that's what I actually wanted
to plot this kind of visual and not get a linear regression if you once also have confidence intervals
and all my data points concerning the cohesion or coherence between amounts and sales.
And that's how easy it is actually to run Python code in Paul VI and this was one example on how you
can create a script from your specific data you already have imported.
Now let's create another script OK.
So what I want to do is let's say I want to see something like the amount in the sales again but now
I want to see them basically may be colored by the specific categories we have.
OK.
So how can I do this again.
What I would do is simply select my Python script.
I got my part of the script I can drag and drop it to play around.
And then I need to put in specific data at first.
So in this case again I'm using the amount striked the amount it devalues then I would also use my sales
direct the sales and values.
And then this time I also like to have that category.
Okay you're in that category and drag it into Bally's.
So the order here doesn't matter.
Okay simply drag the specific columns you want where you want to create your data frame from into the
value area.
Now I can select it and you can choose how you want what you want to do basically run your appear.
What you say or what I'm saying here is I will import my Iberis again I'll say imports matplotlib lap
dot pipe plot plot as well as an abbreviation and I'll do the same for sibilance import seaborne S S
and S and then I'd like to say in this case again I want to use the L-M plot in this case as and as
Daas dot that and plot.
But this time I need to do a few specific things so I say x is equal to my sales.
So sales putting in quotes Y is equal to.
In this case the amount again.
So we already covered this.
And now the data again the data is equal to data sets data sets so this is exactly the same as before
but this time we say that we do not want to see for instance this linear line here.
If you don't want it we can simply say the fit rack fit on the school rack is equal to faults.
And then so we specify that we do not want to see the regression line and then we see say we want to
actually have a different kind of colors for all these points we have.
And let's say we want to color them by what I said the category and that's why we tracked the value
of this field in the valleys here.
So by the way you can use any of your columns which is in Python which if you do not drag this into
values.
OK.
So be aware of that.
So in this case that's why the reason why I attract categories here and I say in this case I want my
color which is in python here in hue.
And I can say is equal to and like and specify in quotes category category and then I also say in this
case or let's say that circles is first and then let's say Piazzi don't show OK to.
Tito show to parenthesis at the end.
Let's take a look what this looks like.
OK.
I run the python script and wait until we are.
And here we go.
That's what we have again.
What you see is we see only single points the reason again is exactly the same as we had before.
So always keep this in mind please if you have numerical value.
You need to right click on this and say don't summarize because you want to see all the data in your
data set.
OK so kind to summarize but the say it's also don't summarize and then this is what it gets.
Just wait until it's done.
And now the calculation is finished.
And that's what we get as an output.
So maybe we would like to adjust this of course because you can see that the legend here is somewhere
in the middle right.
So this is not what you want.
Instead we would like to place it maybe on top here.
So it does not overlap with certain data points because I can see there's data point behind fruit in
this case so I could say that I'm going here in the plot and say that I get rid of the letter sent by
the D4 legend so I could say for instance legend is equal to false.
So this simply removes this last year.
And and that's what I do is I'm using T.
So I met prototype and say Pierre T-top legend legend and then I say once the location is equal to in
quotes upper right.
OK.
So I want to place it right and it closes parenthesis.
And then I press the wrong button press run and just wait until it's done and the condition is done
and I can see now the legend is up here.
OK.
And doesn't that overlap this data points you for drinks in this case.
OK.
So this is the second visualization kind of similar to the first one but a little bit different because
we played around with the colors which we can enter here as well as a legend.
And I mean this should not be a python course so don't don't get this wrong but I just want to show
you a few visuals what you can do when you use one for instance and how you can implement this in in
if you're in Paul VI and you can see that it looks exactly the same way as it would in a normal Python
or almost.
OK.
So that's it for this video I don't want to make this too long because this was a put which I got from
other courses that are short and shorten the video so we'll do a few additional visualizations which
I want to show you in the next video.
OK.
So as always thanks a lot for watching and hopefully see you in the next one.
Until then guys.