Live data from Hacker News

My thoughts on Python in Excel

xlwings.org

1–10 of 123 posts

Re: My thoughts on Python in Excel

#2
Without interacting with it myself, none of this is surprising.

I have used excel in the past, and I am a long term python user. But if you asked me today what I really wanted to make my life easier and ultimately a product or business better using only excel? I would ask for lua or scheme. I don’t need a batteries included environment embedded into a spreadsheet. I just want sane syntax for common functionality which does not require arcane knowledge and long forgotten wisdom.

Re: My thoughts on Python in Excel

#3
post #2

Without interacting with it myself, none of this is surprising. I have used excel in the past, and I am a long term python user. But if you asked me today what I really wanted to make my life easier and ultimately a product or business better using only excel? I would ask for lua or scheme. I don’t need a batteries included environment embedded into a spreadsheet. I just want sane syntax for common functionality whic…

Your personal use-case might prefer Lua or Scheme, but most casual Excel (or SQL) users are non-programmers so they won't. They'll want the equivalent of decently-documented macros or boilerplate they can easily and quickly use without modification. (One common Excel use-case will clearly be "import/munge lots of data from various sources, then pass it into some AI model, then process the output". Can't see people writing that in Lua.) The real target customers for this one are commercial/enterprise non-programmer Windows-stack users whose legacy workflow/data is built around/glued to Excel and are already locked into paying $$ monthly/annual subscription. From looking at Reddit, I don't see much other takeup of Python in Excel.

I don't get your "shouldn't need batteries-included environment" objection; MSFT is bundling Anaconda distribution libraries with Excel. I'd expect it works seamlessly online and offline, as far as everything supported by Python stdlibs. (Can you actually point to any real problem with the batteries?) Really the only part I see you can quibble is things that are currently only implemented in uncommon third-party libraries, i.e. not stdlibs/numpy/scipy/scikit-learn/pandas/polars and the main plotting, data-science, ML, DB and web libraries.

> I just want sane syntax for common functionality which does not require arcane knowledge and long forgotten wisdom.

Show us some Python syntax for common functionality in Excel which does require arcane knowledge and long forgotten wisdom. Otherwise, this is purely your conjecture.

(If anything, bundling Python with Excel will stimulate healthy discussion towards which Python stdlibs need to be added/enhanced/changed, and which third-party libraries should be upgraded to stdlibs.)

Re: My thoughts on Python in Excel

#5
> We wanted an alternative to VBA, but got an alternative to the Excel formula language. indeed

> Integrating the Jupyter notebook cells inside the Excel grid was a mistake. 100% agreed. this seems like the typical Microsoft behavior where the team A was pushing their product and won over team B, even though it's not really what users needed

> Python in Excel isn’t suitable for Python beginners nor for interactive data analysis. exactly. it is my humble opinion that Microsoft doesn't really understand how Excel is used IRL

also this bit is gold:

> What I find interesting though is the multiline editing experience of PY cells. Why not give the native Excel formula language an upgrade, so I don’t have to write LET expressions such as the following one (that I still find very hard to read):

    =LET(x, 1, y, 2, x + y)
> Instead, allow me to write it like so?

    let x = 1
    let y = 2
    x + y
and we haven't even talked about =LAMBDA()!

> Also, why not turn Excel tables into a native Excel DataFrame? Give them attributes instead of sticking to the functional approach and you’d be looking at something like this:

> =MyTable[#All].GROUPBY(...)

> Lot’s of possibilities to integrate the pandas functionality in a way that feels more native to Excel!

Jackpot. I'm literally building this formula language in a new spreadsheet app (it's early days but I'm eager to share it on HN when the MVP is ready!) and am writing a paper on dataframes vs. spreadsheets, so reading this has warmed my heart on this rainy afternoon

also as a former Django lover (I still love it, i just don't use it as much), `=MyTable[#All].GROUPBY(...)` reminds me of its ORM...

"hmm emoji" indeed.....

Re: My thoughts on Python in Excel

#6
post #2

Without interacting with it myself, none of this is surprising. I have used excel in the past, and I am a long term python user. But if you asked me today what I really wanted to make my life easier and ultimately a product or business better using only excel? I would ask for lua or scheme. I don’t need a batteries included environment embedded into a spreadsheet. I just want sane syntax for common functionality whic…

[deleted]

Re: My thoughts on Python in Excel

#7
> PY cells are evaluated from left to right and top to bottom. This includes the sheets, so the first sheet gets calculated before the second sheet, etc.

Oh, no. This is MS Excel 4.0 Macro sheets (Ctrl+F11) all over again, except somehow with a worse execution order.

> It prevents you from referencing a cell with a Python object directly, as you’re always running the risk that someday, someone switches that cell to Values mode, which would break any formula that references this cell in object mode.

That's not a major concern. Excel already has a dozen footguns painted exactly this colour.

> So which output is my df1, and which one is my df2? I have no idea unless I look up the code that is sitting in cells L2 and K2

Excel still lets you name cells, does it not?

> In fact, I agree that the cloud is the best way to bring Python to Excel.

Heretic!

Re: My thoughts on Python in Excel

#8

> PY cells are evaluated from left to right and top to bottom. This includes the sheets, so the first sheet gets calculated before the second sheet, etc. Oh, no. This is MS Excel 4.0 Macro sheets (Ctrl+F11) all over again, except somehow with a worse execution order. > It prevents you from referencing a cell with a Python object directly, as you’re always running the risk that someday, someone switches that cell to V…

> Excel still lets you name cells, does it not?

It does, but that too is a half assed feature so users struggle with it IRL

Re: My thoughts on Python in Excel

#9
post #4

One should note that this comes from xlwings, a Python-in-Excel plugin with a $1,490 professional lifetime license. Excel's changes will end up eating their reason to exist.

While that's fair, the author makes that disclaimer at the start of the article and he specifically addresses where to go with xlwings. But above all, his arguments are right on the money...

Re: My thoughts on Python in Excel

#10
I agree with xlwings about this but for different reasons. MS are a company wot makes money. Python was added to Excel cos R and Python and so on - market share.

I suggest you do what my brother does and unanswer the question! He works for quite a large firm and is surrounded by quite a lot of data. He is a Windows user by routine and asked me for some help. I got Python + MS Visual Code installed and integrated for him and off he went.

He is an expert with the data and its "knowledge" and was willing to roll up his sleeves and get to grips with a grubby data processing facility. He decided on Python and he is my "customer" so I did the best I could too hence anaconda and VS code.

He grabs data out of SAP (he's senior enough to get IT to do his bidding) and then passes that through Python scripts and then passes that on to Excel for reporting.

What many seem to forget is that most apps are chainable. It's often referred to as the "unix philosophy" - each component should do one job and do it well. That's nice but also bollocks when abused as I have just done.

If Python is not integrated properly within Excel then do it yourself via whatever interfaces are available. Pass in and out with .csv or whatever. You just need some imagination.

For me: I use Libre Office and despite owning my company, I don't require everyone else to do so. I believe in freedom and expression of choice.

Post reply on HN