[SOLVED] How can I approach a function that creates plots based on the amount of columns specified>

Issue

Thanks for stopping by to my question..

Basically, I’m new to Python and I just started school and using it as well.

I am currently facing a challenge about making a linear regression model, but my question is geared towards taking a look at the data before actually putting it in the model.

So I had the great idea of making a function that can create several plots based on the values of a column and the number of columns given (just a basic histogram column to see how the data is distributed).

I kinda have an air of how to approach this (for loop, subplot function, changing position of the plot based on the number of plots) but I just can’t figure out where to start and I freeze when trying to do this. I presume telling where the columns are located and the name of the columns that I want to plot would be my arguments.

Can anyone help me? Hopefully, I explained myself correctly. Thanks!

Solution

So, basically, I figured it out…

You need to write a function that uses your dataframe and the columns you want to use. You have to make sure to use * in your columns argument so that you can choose 1 or more arguments (columns in this case).

Then inside your function, you make a for loop in which you say, for every single argument in your arguments, plot it.

That would be it 🙂

Answered By – Jorge Luis Villarreal Treviño

Answer Checked By – Gilberto Lyons (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *