r/learnpython • • Apr 13 '22

What is difficult in excel but easy in Python?

If you were to introduce an established excel user [non VBA] to Python, what would you suggest?

What would amaze them? In as few a lines as possible?

404 Upvotes

241 comments sorted by

View all comments

Show parent comments

28

u/SirGeremiah Apr 13 '22

I doubt it. They didn’t say graphs were better in XL - just easier. And they are. I can knock out an Excel graph from reasonable data in just a few clicks. No matter how good I get at Python, it’ll never be easier for simple, basic charts.

3

u/angry_mr_potato_head Apr 13 '22

df.plot()

8

u/hmiemad Apr 13 '22

Yeah but pivot table + graph is so handy, just drag and drop fields, add filters, one or two intermediate fields, post grouping fields, group per mean, std, sum, any basic stuff. Plus any desk job can open an excel and click a macro button to load a csv and crunch your data into a nice graph that you can copy and paste as an image into a ppt or email.

Of course the power of python is huge, but it comes with knowing how to code. In one week one can learn to make nice pivot graphs, if you know a little math. How long does it take to learn to make an interactive graph with python? Months ! Years if have never coded.

Everything in Excel is visible, every step, every formula, it's user friendy. Link access and PowerBI to create a centralized data lake with dashboards. It's seriously insane how much it can automatically structurate you data.

I won't ever code in VB, hopefully, now that I know python, but I miss the handiness of pivot graphs a lot.

1

u/Ikwieanders Apr 13 '22

With seaborn it kinda is though right? I only use Excel every now and then though, so ofcourse I am not very fast in Excel as well. But still, simple chart in Python takes a few seconds of you have a dataframe.

3

u/SirGeremiah Apr 13 '22

I’d have to see that to understand. I only see Python as a programming language, so the idea of a chart being as easy as a few clicks is like magic to me.

3

u/SuurSieni Apr 14 '22

Creating plots with Seaborn is really fast and easy, but it of course requires the initial effort for the know-how. Not as fast as a couple clicks, but in the ball-park of doing the clicks for several plots. What makes the plotting easy, is the capability to just give data column names as arguments for aesthetic customization and multi-panel plotting.

As an example, consider a data frame df with observations as rows and with columns "person", "location", "height" and "weight". Using df, a scatter plot with variable-dependent marker styles and colors can be created with one command:

seaborn.relplot(df, x="height", y="weight", hue="location", style="person")

To create a plot with multiple panels from subsets of the data, one could for instance add row="location" to the above command to get a panel for each unique location in the data set. There's of course a lot more, but this should suffice.

3

u/SirGeremiah Apr 14 '22

That's very cool. So, really, as with many things it'd be better for some situations where there are variations (like the location) and where we can expect to need to create very similar graphs off very similar data, but not better for one-offs.

2

u/SuurSieni Apr 14 '22

Yes, if the data is processed in Excel then it would be fair to say so. However, as Python is more versatile than Excel, I find that generally it's just simpler to perform entire workflows in Python, R or what-have-you. But YMMV. I do still occasionally use Excel for quick post-processing, if just to provide the results in the receiver's preferred format.

2

u/SirGeremiah Apr 14 '22

I'm generally getting data that's already in Excel (where data is relatively small, that's the de facto standard for delivery in a lot of places).