this post was submitted on 22 Aug 2023
173 points (98.3% liked)

Python

6416 readers
5 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

Microsoft is bringing popular programming language Python to Excel. A public preview of the feature is available today, allowing Excel users to manipulate and analyze data from Python.

You won’t need to install any additional software or set up an add-on to access the functionality, as Python integration in Excel will be part of Excel’s built-in connectors and Power Query. Microsoft is also adding a new PY function that allows Python data to be exposed within the grid of an Excel spreadsheet. Through a partnership with Anaconda, an enterprise Python repository, popular Python libraries like pandas, statsmodels, and Matplotlib will be available in Excel.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 7 points 1 year ago* (last edited 1 year ago) (3 children)

This feels like a really dated take to me. Leaving aside whether this was true in the past, in 2023, Excel is happy to open absolutely gargantuan files, and it's quite speedy once it's done so. You can even directly tie it to a database via ODBC if you want, and that works (albeit it obviously flattens the data out in the process, so goodbye foreign keys in any real sense). It also has tons of very easy-to-use data manipulation tools (pivot tables, tables in general, data extrapolation, graphs, etc.) that end up being wonderful complements to something like Python.

Could you write a Python program that would run faster than pure Excel and do the same thing? I mean, probably (although Excel's core execution engine is honestly pretty freaking fast). But could you write it as quickly? Maybe, maybe not. And certainly someone who knows Excel well would have an easier time adding a little Python to patch up any issues than rewriting the whole thing from scratch.

tl;dr I think you're not being accurate about contemporary Excel, and I separately suspect you're not really the target audience here

[–] [email protected] 2 points 1 year ago (2 children)

I agree with all your points about Excel being capable. However, I'm struggling to think of examples where this newly announced Python integration within Excel would be helpful (with the exception of new/different visualizations) - especially for the reasons you stated about modern Excel.

Are there any use cases that you can think of where someone who knows Excel well would resort to "adding a little Python to patch up any issues"?

[–] someguy3 2 points 1 year ago (1 children)

Probably like me. I knew just enough VBA to do what I wanted in Excel, but not enough to write it from scratch in vba or C++.

[–] [email protected] 1 points 1 year ago (1 children)

What do you mean? This new Python integration cannot accomplish the majority of things capable in VBA or C++ (or even regular Python).

[–] someguy3 1 points 1 year ago (1 children)

I can do basic things in vba. I don't know enough to leave Excel and start writing a standalone program in vba, c++, or Python. I can learn a few commands, but I'm not going to become a programmer.

[–] [email protected] 1 points 1 year ago (1 children)

So you're saying that you're more likely to use Python in Excel than Python outside Excel?

If you're "not going to become a programmer", wouldn't it just be better to learn the extra Excel formula or two instead of learning Python, Python data structures, Pandas, etc. in addition to how all that works within Excel?

Learning how to use HSTACK(), VSTACK(), XLOOKUP(), and other newer Excel fomulas will likely be much easier than understanding how to do the equivalent in Python.

[–] someguy3 1 points 1 year ago

I would never use Python outside of Excel just like I never use visual basic outside of Excel.

I would use it for the same reason I (rarely) use vba in Excel, some things you can't do with formulas.

[–] [email protected] 1 points 1 year ago (1 children)

Maybe some sort of "team toolbox" of logical functions or something? I've seen some nightmare shops where big reports have a page of manipulations that get copied to new reports/projects every time, and each represents some sort of canned, core business logic.

I dunno. I cant imagine how the code storage will go

[–] [email protected] 1 points 1 year ago

The code storage for Python is no different than regular Excel functions (eg - VLOOKUP(), SUM(), etc.), meaning that it is stored within an Excel cell. The only differences are that Python code is run remotely vs Excel functions running locally and the location of Python's code matters vs Excel's functions are location agnostic (ie - Python code runs in cells located left-to-right, top-to-bottom but Excel's functions can dynamically determine the calculation order/location).

I'm not sure that this new Python integration changes much about this use case (except for another way to accomplish the same/similar tasks).

[–] [email protected] 2 points 1 year ago

Could I write a Python program that does the same thing as Excel but faster?

I don't need to. It's called pandas

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

I hear you.

I don't know how new Excel performes and I thought it's the same as ten years ago - the version I'm trapped in. With people who obsessively try to drive it to the edge where it's not responsive on average office PCs.

But if it works well with various big spreadsheets now, it's a wonder, with how many new people start to tackle programming with Python. I obiviosly won't write a script faster than normal operational speeds of software, it's just some tables ended up that big and broken I could only open them like that. But that, I guess, is exclusion?

It's just the issue of people using a microscope as a hammer when they need to break nuts.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

So, assuming you're still on Office 2010, you're missing (off the top of my head, but I believe these were all Excel 2013 or later):

  • Initial support for super-large spreadsheets, with accompanying perf improvements (this was maybe 2013?), and then lots more perf improvements in 2016 and 2019 as people started using those really big sheets;
  • Flash Fill support, which is kind of like an AI (not in the ChatGPT-sense)-powered fill down (so e.g., nowadays, if I enter "Sept 6th" and then "October 4th", then it'll offer a completion of November 1, since that's the first Wednesday of the month);
  • Heavily improved Pivot Tables, including Slicers, Power Pivot, and Pivot Drill Down, which make exploring data a lot easier;
  • Forecasting tools; and
  • Much better Tables, making it a lot easier to write formulae entirely with named references rather than cell IDs There's more, but that's what I could remember off the top of my head/could quickly verify so I was sure I wasn't misspeaking. LibreOffice Calc unfortunately also lacks basically all of these features (and the lack of Tables in particular means that OpenOffice sheets still have a lot of A2:A300 garbage where Excel would instead just have e.g. SomeTable[Heading]. E.g., an actual formula from a sheet I currently maintain to track my team's sprints: =XLOOKUP([@Verified],SprintMeta[Start],SprintMeta[Sprint Name],"Unknown",-1). Python's easier to read here, but this is honestly doing a lot while being surprisingly readable (especially if you're familiar with XLOOKUP, which is basically how you do keyed array access in Excel)

You have totally legitimate gripes about Excel; I'm not denying that. But I do think that you might be pleasantly surprised on newer versions.