News for hackers. Stuff that matters.
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @07:12PM (#25587964)
I'm a research actuary working in reinsurance. Here is why I think Python creates more problems than it solves from the standpoint of most insurance business users:

1.) Environment management. There are many solutions for managing python dependencies, my favorite is Docker + pip. Good luck getting actuaries and underwriters to write Dockerfiles etc, and good luck getting I.T. to support Docker on Windows desktops. Like it or not, the best "feature" of Excel is that it is mostly the same on every corporate Windows machine.

2.) Unless you are using numpy / numba, Python isn't that much faster than VBA (if at all). Both are "compiled" to interpreter bytecode.

3.) Speed of development and traceability. Excel takes a lot of getting used to, but if you know the purpose of the spreadsheet (e.g. a reserve calculation), it's relatively easy to figure out what a mangled and convoluted formula is doing (Excel has a "debugger" that allows you to evaluate formulas by highlighting pieces).

4.) LAST BUT NOT LEAST. Many financial and actuarial (insurance) calculations are inherently recursive. Excel has built-in memoization (in the dynamic programming sense). It also has a reactive programming model. Good luck implementing that in Python without tripping up on the huge amount of function call overhead, even if you use a memoization decorator.

Re:Ditching Excel for Python in a legacy industry by SoSoRoCoCo on Wednesday December 30, 2020 @07:20PM (#25588018)
It is great that you respond with succinct reasons.

People who have used Python for some years seem to forget just how clunky it really is. I've been using Excel since 1990, and sure, it has its own warts, but Python is a very rudimentary tool compared to Excel.

Python is a machine shop. Excel is a car. It may be a lemon, but it's a functional car.

This is a great example of programmers not being able to see the forest for the trees. Reminds me of the "Once Linux gets a desktop it will take over the world" debate from circa 1997-today.

Re:Ditching Excel for Python in a legacy industry by trimbo on Wednesday December 30, 2020 @08:14PM (#25588419)
> Reminds me of the "Once Linux gets a desktop it will take over the world" debate from circa 1997-today.

Linux did take over the world, just not on the desktop. It was on servers and mobile, which now have more users than desktops or laptops (edit: servers via the web).

Technology gets its warts fixed when it grows along an explosive new market, especially if the market ends up being larger than the last.

Python is currently riding the data science wave, and that wave is growing. If that market expands to the point where large scale data-science type work wags the dog of VBA/excel, the clunkiness[1] will work itself out.

[1] - I don't actually understand what's clunky about Python in the context of the article. Seems like a reasonable direction in a complex market (reinsurance) driven by actuaries. I'd be surprised if newgrad actuaries/stats people aren't using Python?

Re:Ditching Excel for Python in a legacy industry by SoSoRoCoCo on Wednesday December 30, 2020 @08:42PM (#25588616)
Absolutely. I worked at Intel and our distributed computing pools went from a combination of SunOS and AIX machines to Linux in about 3 months, essentially overnight, (back in the 90's). It was an astonishingly fast deployment.

Linux dominates the server world AND the entertainment device world (hello busybox & gstreamer!)

[1] Regarding clunkiness of Python: mostly it is the packages, installation, and 2.x vs 3.x nightmare that persists. Everyone seems to forget the initial pain getting the Python env to work, esp. when it comes to cython native compilation issues / arch wheels, unsupported packages, etc. The only issue I have with python is it is extremely challenging to make cross-platform deployments for single-executables. I've tried three different approaches and they were all trainwrecks. Once that is ironed out, I'll be switching from Electron to whatever Python offers.

Re:Ditching Excel for Python in a legacy industry by nl on Wednesday December 30, 2020 @09:25PM (#25588914)
I think the 2.x vs 3.x issues have mostly been resolved by now. I don't think I've hit one for a long time, and even StackOverflow answers are more likely to be Python 3 now.
Re:Ditching Excel for Python in a legacy industry by SoSoRoCoCo on Wednesday December 30, 2020 @10:07PM (#25589160)
macOS still ships with Py2.7 and has dependencies, and npm-gyp only recently switched to 3.x. same with python SDR. it depends what you use: less popular packages are still languishing.

but that discounts the tens of thousands of projects that are already out there that are in use and need conversion.

it'll take probably 3-5 years for it to really go away.

Re:Ditching Excel for Python in a legacy industry by nl on Wednesday December 30, 2020 @11:54PM (#25589705)
Yes, that's true. And aren't some versions of RedHat still on 2.7 too?

But I class this as a packaging issue more than a 2.7 vs 3.x issue: you see the same problems with (as a random example...) different versions of OpenCV - people not using virtual environments have problems even if they are all on 3.7.

When I think of the "2.x vs 3.x problems" I was thinking more of the language and core libray level incompatibilities.

Re:Ditching Excel for Python in a legacy industry by buryat on Thursday December 31, 2020 @01:52AM (#25590244)
macOS ships with both py2.7 and 3.7, `python` would call 2.7, and `python3` would 3.7
Re:Ditching Excel for Python in a legacy industry by vimy on Thursday December 31, 2020 @07:50AM (#25592166)
As of macOS 11.0 there is no python anymore. You have to download it.
Re:Ditching Excel for Python in a legacy industry by SoSoRoCoCo on Thursday December 31, 2020 @12:48PM (#25594978)
Really? YAY!!! I upgraded to Big Sur and it is still there... but I don't know if it is a legacy since I've been TimeMachining my machines since 2012 and things persist.
Re:Ditching Excel for Python in a legacy industry by vimy on Thursday December 31, 2020 @08:01PM (#25599459)
Hmm apologies, I was wrong.

The Catalina release notes[1] said they would remove it and I was sure they mentioned it again in this year’s WWDC but apparently it’s still included after all.

[1] “Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app.”

Re:Ditching Excel for Python in a legacy industry by noir_lord on Thursday December 31, 2020 @06:08AM (#25591622)
> Linux did take over the world, just not on the desktop.

I'm honestly not sad that it never happened.

It took over my desktop around ~1998 and I wonder if massive adoption of Linux on the desktop would have benefited me or been worse (from my perspective).

As it stands literally every single tool I want/need to do my job is already available for Linux and indeed many of those tools are simply better on Linux (docker on a mac is horrible, I have a work issued current gen macbook pro, I use it purely for testing docker set-ups and then it goes back in its case).

Its going to sound elitist but not dumbing down the platform for the average user is a benefit to me.

Re:Ditching Excel for Python in a legacy industry by danieldk on Friday January 01, 2021 @08:06AM (#25602980)
Well, it would certainly make may day live easier if we had Microsoft Office, the Affinity Suite, and Lightroom on Linux, which would probably have happened if Linux was the dominant desktop.
Re:Ditching Excel for Python in a legacy industry by atoav on Thursday December 31, 2020 @02:46AM (#25590548)
Depends really on your proficiency at python and the task at hand. For many "small fry" tasks Excel is perfectly fine and faster. Good when the table data is meant to be in foreground.

For things where data exploration and formulas should be in the foreground or where data and formulas should be strictly separated python (or a python/jupyter notebook) has tangible benefits (e.g. really good list syntax).

Re:Ditching Excel for Python in a legacy industry by rualca on Thursday December 31, 2020 @08:54AM (#25592690)
> "Once Linux gets a desktop it will take over the world" debate from circa 1997-today.

Pretty much all servers run on linux.

Linux also dominates smartphones in the form of Android phones.

Chrome OS is also linux, and it's market share is currently at around 6%.

I mean, other than desktops Linux pretty much is everywhere.

Re:Ditching Excel for Python in a legacy industry by pjmlp on Friday January 01, 2021 @04:21AM (#25601941)
> Linux also dominates smartphones in the form of Android phones.

Not really.

See any Linux specific APIs on the NDK official APIs?

https://developer.android.com/ndk/guides/stable_apis

Android is a mix of Java and Kotlin based frameworks, ISO C and C++, POSIX subset and a couple of additional libraries.

Whatever kernel gets used is an implementation detail for Google and Android device makers.

Can be completely replaced in Android 12, and the eco-system would continue to work.

> Chrome OS is also linux, and it's market share is currently at around 6%.

Basically Android (already mentioned above) and Web stacks.

https://chromeos.dev/en/android-environment

https://chromeos.dev/en/web-environment

Ah, but it does expose Linux you say, https://chromeos.dev/en/linux

Indeed, except of the small detail that as shown on the Google IO talk, it is actually a design similar to WSL 2, running a second kernel on a hypervisor based environment.

The real kernel powering ChromeOS doesn't get exposed to userspace and can also be replaced at any time, if Google so desires.

In fact, in a near future Android and ChromeOS can be running on top of Fuchsia and most consumers wouldn't even notice.

Re:Ditching Excel for Python in a legacy industry by fock on Wednesday December 30, 2020 @07:37PM (#25588147)
I wonder what the problem is with standarizing companywide around [email protected], [email protected] and [email protected]. At this point these can all be considered mature and why on earth would an org, which is not developing these packages, nor heavily consuming outside code (because they didn't with excel either in a sensible way?) decide to jump on the "but we need rrrrrollling release"-fad bandwagon?
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @07:45PM (#25588212)
The problem isn't feasibility, it's resources. Building and rolling out a standardized environment, and maintaining it, will cost millions of dollars. It shouldn't, but it does. And for what added benefit? The end-users don't want it, you'd have to spend another couple million for a lateral move at best. More than likely, you'll end up with a pile of Python spaghetti code that runs slower than the spreadsheet (see point #4 about massively recursive calcs).
Re:Ditching Excel for Python in a legacy industry by shnock on Wednesday December 30, 2020 @07:52PM (#25588267)
Why does building and rolling out a standardized environment cost so much? Could you break down the requisite steps and resources required to achieve this?

Thank you, I appreciate it :)

Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @08:08PM (#25588377)
Up-front costs (mostly salaries, but all I.T. projects are "billable") 1.) Getting buy-in from solutions architect, software architecture, information security, I.T. management. This will be a 6 month process. 2.) Getting buy-in from actuarial management and audit. Another 6 month process.

Recurring annual costs (over 10 years) 3.) Contractor at $150 an hour = $300K annually 4.) Contractor PM at $50 an hour = $100K annually 5.) Information security compliance hoops, getting it to play nicely with the myriad of endpoint security tools, etc 6.) Ongoing maintenance and support (failed rollouts and upgrades, user desktop support, user training)

Re:Ditching Excel for Python in a legacy industry by tomnipotent on Thursday December 31, 2020 @01:49AM (#25590228)
This isn't realistic at all. Assuming actuaries know Python like they know Excel, the only other added cost is someone technical to slap together a working environment, which isn't particularly hard when compared to the state of what Excel offers in a collaborative environment.

You just don't jump from "humans in Excel" to "CI/CD perfected pipeline" overnight, nor do you need it.

Excel shops still have costly expenses rewriting entire workflows/re-doing Excel files constantly as people come and go, it's not like there isn't already maintenance cost with the current method.

Re:Ditching Excel for Python in a legacy industry by buryat on Thursday December 31, 2020 @01:54AM (#25590258)
reminds me of standardization of the shipping container, not sure of all the details of how that push had happened though
Re:Ditching Excel for Python in a legacy industry by sam_bristow on Wednesday December 30, 2020 @10:06PM (#25589152)
Funny story about Excel on corporate machines. A couple of years ago the company I work for got boight by an Italian company. When we finally migrated the Windows users over to the corporate Office installs a bunch of people found that Excel wouldn't work for them. Things like sum(A1:A20) were syntax errors.

After a bunch of digging i worked out that the localisation from corporate meant they suddenly had Italian function names not English. Very confusing.

Excel is a program that is both incredible and terrifying to me. There are ways of building spreadsheets that are reliable and auditable. Then there's how 95% of people do it.

You can start out really quickly and make great progress. But it tends to grow and metastasize before you know it.

Re:Ditching Excel for Python in a legacy industry by etothepii on Wednesday December 30, 2020 @11:48PM (#25589691)
It must be easier to build an auditable and reliable solution using a high-level language programming language and concepts like source control and automated testing.

Excel is only easier if you aren't interested in building something auditable and reliable solution that might have some hope of being maintained after you have left the company.

Re:Ditching Excel for Python in a legacy industry by sam_bristow on Thursday December 31, 2020 @12:07AM (#25589795)
That's the thing, most Excel workbooks start out as a one-off then gradually get adapted and extended until they're load-bearing.

They're often built by specialists in another dept who definitely wouldn't consider themselves programmers.

Doing it 'properly' would probably mean having to spec put the problem, get a budget, maybe wait a few months for someone to look at it. And the same thing every time the requirements change.

Excel is available today and they can get started solving their immediate problem straight away.

After it's been in use for a couple of years and shown value someone takes a look and sees the Lovecraftian horror it's become.

Re:Ditching Excel for Python in a legacy industry by tomnipotent on Thursday December 31, 2020 @02:04AM (#25590308)
> until they're load-bearing

This cannot be stressed enough. I've outlived generations of finance teams at many startups, and I've seen firsthand the masterpieces/abominations left behind in Excel. Imagine a dozen sheets with ad-hoc queried data copy/pasted from System A/B/C/D into Excel, with formulas that feed formulas that feed formulas. Sometimes columns are inputs (seasonality adjustments for monthly forecasts), sometimes their outputs (modeled growth * last year * seasonality adjustment) and more often than not their right next to each other and maybe they have different cell background colors or a black separator line. Maybe.

And this is just finance. For many e-commerce businesses, planning is done in Excel with equal zeal.

Re:Ditching Excel for Python in a legacy industry by sam_bristow on Thursday December 31, 2020 @02:41AM (#25590515)
I remember hearing about a mythical spreadsheet floating around for modelling something to do with our national grid a few years back.

It would take about 12 hours to calculate, and would error out before finishing about 30% of the time. It needed to be run once a day for something reasonably important.

I don't use Excel much these days, but I do point people to a video if they do plan on doing anything:

* [You suck at excel - Joel Spolsky](https://m.youtube.com/watch?v=0nbkaYsR94c)

Re:Ditching Excel for Python in a legacy industry by rvba on Thursday December 31, 2020 @08:36AM (#25592527)
Someone who does not use Excel nice will probably make spaghetti code as well.
Re:Ditching Excel for Python in a legacy industry by larrywright on Friday January 01, 2021 @02:22PM (#25605900)
I'd rather reverse engineer spaghetti code than a spaghetti Excel spreadsheet.
Re:Ditching Excel for Python in a legacy industry by JackoM on Monday January 04, 2021 @11:46PM (#25642219)
Most probably because you do not know Excel !? But for someone who do know well Excel and understand finance concept it'd be easier to understand the spaghetti Excel spreadsheet and find where it doesn't work properly !
Re:Ditching Excel for Python in a legacy industry by empthought on Saturday January 02, 2021 @06:57AM (#25612189)
You’ve been lucky with your spaghetti code experiences, then.
Re:Ditching Excel for Python in a legacy industry by larrywright on Saturday January 02, 2021 @06:17PM (#25617589)
At least with spaghetti code I can set a breakpoint or add print statements and get an understanding of the execution path.
Re:Ditching Excel for Python in a legacy industry by Mauricebranagh on Thursday December 31, 2020 @04:56AM (#25591243)
And you find a bug that costs you $$$$,

I worked for a company that used an opaque excel spread sheet as a part of its accounting system - turns out there where bugs and we found a massive short fall one of the contributing factors in the collapse of the company.

Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @05:08AM (#25591310)
This is the real problem. It's not with excel per se, but the complete lack of automated testing and source control.
Re:Ditching Excel for Python in a legacy industry by fnord123 on Thursday December 31, 2020 @06:00AM (#25591589)
Python works with source control and tests so this would indeed be a problem with Excel per se.
Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @08:14AM (#25592332)
But Python doesn't have to, I've seen plenty of python with 1000 line functions, no tests and no source control. It's particularly common in Jupyter Notebooks.
Re:Ditching Excel for Python in a legacy industry by mehrdadn on Thursday December 31, 2020 @02:13AM (#25590353)
> There are ways of building spreadsheets that are reliable and auditable. Then there's how 95% of people do it

Do you have any pointers to learning materials on how to do this? Would be interested in reading more on it.

Re:Ditching Excel for Python in a legacy industry by sam_bristow on Thursday December 31, 2020 @02:53AM (#25590574)
This Twitter thread is a good start: https://mobile.twitter.com/keith_ng/status/13079610874515251...

There also Joel Spolsky video I linked in another comment: https://youtu.be/0nbkaYsR94c

I don't actually use Excel much so others might have better resources.

Re:Ditching Excel for Python in a legacy industry by mehrdadn on Thursday December 31, 2020 @07:00AM (#25591887)
Oh I've already seen the Spolsky video, but I seem to recall for the most part (except for using tables, which is great) it's about how to use Excel effectively, not about how to produce maintainable sheets. The Twitter thread looks good though. Thanks!
Re:Ditching Excel for Python in a legacy industry by unixhero on Thursday December 31, 2020 @06:12AM (#25591640)
Localisation is where you first have to debug Excel formula errors. Is it colon, or semicolon; it responds to, is my goto method to approach the issue.
Re:Ditching Excel for Python in a legacy industry by HALtheWise on Thursday December 31, 2020 @09:15AM (#25592826)
This brings up a good point, which is that Excel supports localization, while Python just assumed you know English.
Re:Ditching Excel for Python in a legacy industry by stochastastic on Wednesday December 30, 2020 @08:26PM (#25588487)
Hey fellow reinsurance actuary! I totally agree that Excel has its place in modeling, especially one-offs, and your criticisms make sense. That said, we have been moving a lot of our calculations to Python. We have had way too many rickety tools to move files or send emails (“first you open this spreadsheet and click this button, then you open this spreadsheet and click this button, then...”), and way too many version control issues over the years. Python solves those nicely.

I’m curious about docker + pip, why do you like that better than poetry or pipenv?

Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @08:48PM (#25588656)
One reason why Python is so successful is that it places very nicely with C code. Many of Python's libraries are thin wrappers around native DLLs.

For example, numpy is a wrapper around a BLAS DLL (e.g. Intel MKL). Pipenv manages the python side of things, but don't exert control over the system DLLs (like Docker does). Anaconda gets very close to what Docker does (by managing DLLs). Have not used poetry, so can't comment.

Ultimately, like most dependency management issues, lacking a stable DLL environment won't be a problem until it is :)

Re:Ditching Excel for Python in a legacy industry by lldbg on Thursday December 31, 2020 @12:57AM (#25590011)
numpy is much more than a wrapper around a BLAS dll. BLAS implements three sets of operations: Level 1: unary and binary vector vector operations, one transform. Level 2: Matrix vector operations. Level 3: Matrix matrix operations (most famously the dgemm routine).

Perhaps some blas implementations offer more features, but that would defeat the purpose of a standard interface.

Re:Ditching Excel for Python in a legacy industry by stochastastic on Wednesday December 30, 2020 @09:51PM (#25589062)
Okay, I can totally see it now. We are still at the stage where people seem to think that I’m neurotic for worrying about the python side of things, so DLLs have not been on the radar. ;)
Re:Ditching Excel for Python in a legacy industry by z3t4 on Thursday December 31, 2020 @11:25AM (#25594064)
In Nodejs native libraries are a PITA. The compatibility API breaks on a schedule every 6 month, dependencies get updated by OS distros sometimes breaking stuff, then you rely on the OS being able to compile the library. I hope Python has better native interop.
Re:Ditching Excel for Python in a legacy industry by syndacks on Thursday December 31, 2020 @02:34AM (#25590475)
Much like the referenced Excel spreadsheets becoming unwieldy, so does a dev's machine [0].

0. https://xkcd.com/1987/

Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @04:53AM (#25591221)
It would be considered incredibly bad practice for such a dev's machine to be used to perform almost any calculation of significant business importance. It's why mediocre Tech Executives are able to appear like they got some work done by focusing on "no access from dev to production."

With Excel there is no such separation, and when there is it would make a great punchline to an XKCD or Dilbert cartoon.

Re:Ditching Excel for Python in a legacy industry by newdude116 on Thursday December 31, 2020 @05:39AM (#25591497)
From the submitted link:

"The desire to price increasingly complex deals with increasingly large datasets"

Bingo! Most people use Excel when they actually should use a database. I am sure you can use Excel with a database like MS Access, but then again, who does?

To your arguments: 1. " and good luck getting I.T. to support Docker on Windows desktops." Yah. Great experience to work with Excel on Linux.

2. You can always link compiled code for stuff that needs to be fast. But in the end most people wont use neither python nor Excel for HFT

3. " it's relatively easy to figure out what a mangled and convoluted formula is doing"

https://www.sciencemag.org/news/2016/08/one-five-genetics-pa...

https://www.washingtonpost.com/news/wonk/wp/2016/08/26/an-al...

https://www.sciencealert.com/excel-is-responsible-for-20-per...

4. Maybe. Not sure it is really an issue.

Re:Ditching Excel for Python in a legacy industry by cutler on Thursday December 31, 2020 @12:50PM (#25595009)
The case for using a database with Excel is at least as strong as for using Python or C# to model Excel data. There are excellent free adapters for MySQL and PostgreSQL.
Re:Ditching Excel for Python in a legacy industry by RobinL on Thursday December 31, 2020 @03:33AM (#25590770)
I think these are all fair points and a good reflection of the downside of Python. But there are also some pretty huge upsides. My view is that for any model of significant complexity, the pros of Python outweigh the cons from a technical point of view.

- Abstraction. It's very difficult to effectively abstract parts of a model in Excel. It's a bit like a doctor having to 'model' a human being as a collection of atoms, rather than having abstractions like organs, cells etc. This makes it very hard to build re-usable components, so analysts end up reinventing the wheel. You also quickly hit a 'complexity ceiling' in Excel, above which mistakes and errors becoming much more likely, and complexity is very difficult to manage.

- Existing libraries provide a huge range of sophisticated calculations and operations for which we don't need to write any code.

- Separation of concerns - particularly separating data from model. Easy in Python, hard in Excel. Another aspect of this is that using data science software promotes the use of tidy data[0] (i.e. clear thinking about how data should be structured).

- Unit/integration tests. For complex models, these are essential. Users of Excel (even extremely clever/competent people) don't have have a great reputation for producing error-free spreadsheets, and I think this is an important reason why, alongside copy-paste errors. The tools for testing in Excel/VBA are rudimentary.

- Version control. This is particularly important for historical reproducibility because it allows us to run past models, and also understand what has changed in the codebase since.

I appreciate some of the above is also possible in VBA, but if you're writing an entire model in code and not really using Excel at all, my view is it's better to use a more sophisticated programming language.

There is also an important cultural point of having to re-skill everyone, and I can see that in some context that means in the short run at least, Excel/VBA may still be better overall.

I've written a bit more about all of this here: https://www.robinlinacre.com/transforming_analytical_functio...

[0] https://vita.had.co.nz/papers/tidy-data.pdf

Re:Ditching Excel for Python in a legacy industry by pjmlp on Thursday December 31, 2020 @08:38AM (#25592542)
> I appreciate some of the above is also possible in VBA, but if you're writing an entire model in code and not really using Excel at all, my view is it's better to use a more sophisticated programming language.

Which is why many VBA experts eventually adopt VB.NET instead of jumping into a complete foreign language, with the benefit that is actually compiled to native code (JIT/NGEN), if performance is ever an issue.

Re:Ditching Excel for Python in a legacy industry by cutler on Thursday December 31, 2020 @12:45PM (#25594950)
Yes, I was wondering why Python was the automatic choice considering C#.Net has typesafe native APIs for Excel on Windows.
Re:Ditching Excel for Python in a legacy industry by RobinL on Thursday December 31, 2020 @01:32PM (#25595506)
I was more thinking about migrating away from Excel fully rather than interfacing with Excel from Python.

I agree that to interact with Excel programmatically VBA is a better choice (and no doubt C#/VB.NET as well, but I have no direct experience). For what it's worth, for interacting with Excel and Office more generally, I've always though VBA is extremely well designed.

Re:Ditching Excel for Python in a legacy industry by jandrewrogers on Thursday December 31, 2020 @12:06AM (#25589785)
I use both Excel and Python, and like both. They solve different kinds of problems, even within the same context.

Excel is fantastic for what I would describe as linear modeling, building a graph of effects in single data models. I reach for Python when I need to fundamentally transform the data model at points to answer the desired question. That is difficult to the point of being impractical in Excel, especially if the data model is large or exploratory. Python is more programmable in this regard but also lacks the strong static typing that would be useful in such work.

I can’t imagine not using either.

Re:Ditching Excel for Python in a legacy industry by sriku on Thursday December 31, 2020 @09:20AM (#25592861)
If you have valid reasons to make the move from Excel to Python, why not consider Julia? Environment is easier to manage (Pkg.add), the language "looks like Python and walks like C", math-friendly style possible, just-ahead-of-time compilation resulting in high performance (enough to not need native code implementations), interactive development (Jupyter was named for Julia-Python-R after all), @memoize may be enough for you and Pluto gives you reactive notebooks.

Bonus - tools are also emerging to make stand alone distributables.

Disclaimer: I neither work for nor am I affiliated with Julialang. I just use it.

Re:Ditching Excel for Python in a legacy industry by mint2 on Wednesday December 30, 2020 @09:37PM (#25588976)
Why do actuaries refer to workstation/desktop computers with more than 16 cores as “super computers” it’s embarrassing but sometimes I give in an say “the super computer” because I’m in a hurry and they’ll give me a blank stare if I call it a workstation or anything like that.
Re:Ditching Excel for Python in a legacy industry by mark-r on Wednesday December 30, 2020 @10:37PM (#25589328)
They really are supercomputers though. Do you know how much faster a modern PC is compared to say a Cray-1? Especially if it has a decent graphics card.
Re:Ditching Excel for Python in a legacy industry by mint2 on Thursday December 31, 2020 @04:14PM (#25597204)
So a typical actuary’s technological reference point is stuck in 1985? That explains a lot about excel and sas egp. But seriously, calling a fairly standard computer in the tech world a “supercomputer” is just another example of the underlying attitude in insurance that makes many actuaries recoil in horror about the thought of “programming” aka learning python or any programming best practices.
Re:Ditching Excel for Python in a legacy industry by ryukafalz on Thursday December 31, 2020 @11:08AM (#25593899)
Yeah but at this point my phone is comparable. If being faster than a Cray-1 qualifies something as a supercomputer, the definition is meaningless now.
Re:Ditching Excel for Python in a legacy industry by mch82 on Wednesday December 30, 2020 @07:51PM (#25588257)
> problem #1: Environment management

Great observation. Python environment management is getting simpler, but is off putting for people without a software background. Unclear even CS majors get enough classroom exposure to package & dependency management to utilize Python efficiently.

I’m more optimistic about an on-prem deployment of Jupyter Notebooks or Sage Math Cloud as a way to hide a lot of the setup complexity. More like a wiki for math. Curious if anyone has stories/tips to share (good or bad)?

Re:Ditching Excel for Python in a legacy industry by everling on Thursday December 31, 2020 @07:10AM (#25591933)
Quant here, at my firm we've deployed a JupyterHub server which provides users with a production docker image, so that analysts and portfolio managers can perform analyses without installing python, dependencies and sql drivers locally. It is working well and spurs interest in Python across the wider org - so we let everyone use it.

Similar to in OP's case, I think the real selling point of Python over Excel is advancing the capabilities and the scale of the business. Talks of different programming languages falls on flat ears in finance - show what can be done instead. With Python, Zipline and notebooks I can manage a global equity portfolio, continuously adding active strategies and adapting to real-world changes and constraints. And backtest! Excel is great, but there is an upper bound to what can be reasonably done without a thriving open source community.

Re:Ditching Excel for Python in a legacy industry by klelatti on Thursday December 31, 2020 @09:23AM (#25592882)
That's really interesting. I've been working on a JupyterHub / JupyterLab / Python based product for the insurance industry - choosing this for all the reasons you've cited. Would be really interested if there are any points you can share e.g are you using Kubernetes and if so how have you found it?
Re:Ditching Excel for Python in a legacy industry by everling on Friday January 01, 2021 @06:10AM (#25602429)
We use Kubernetes, according to our IT/devops guys it was pretty straightforward to deploy in Azure with Jupyterhub's KubeSpawner module + documentation. A few people are quite eager to learn Python / code in general, so we try to make it convenient. One common use case would be to work with existing excel spreadsheets, so the notebook volume storage should be mountable in Windows. The file upload/management in notebook servers is quite obtuse IMO.

If a recurring task can be reasonably parameterized then a Streamlit app might be a better choice in some instances. I've developed a monitoring application for our portfolios where I can track daily asset weights, underlying data points, computations etc. Not displaying code ensures that the output can be consumed by a wider audience.

Re:Ditching Excel for Python in a legacy industry by klelatti on Friday January 01, 2021 @07:51AM (#25602913)
Thanks especially for the Streamlit suggestion.

We've tested JH with K8 in GCP which was straightforward also. With a small team though tending towards a single VM deploy (based on "The Littleist JupyterHub") which looks a lot easier to maintain.

Re:Ditching Excel for Python in a legacy industry by mch82 on Thursday January 07, 2021 @03:46PM (#25677221)
Thank you for sharing.
Re:Ditching Excel for Python in a legacy industry by techphys_91 on Wednesday December 30, 2020 @08:08PM (#25588378)
Is this really an issue for the use case being described? Environment management is obviously a significant consideration for software developers who need to keep track of versions etc, but it sounds as if these users primarily want to use the fundamental numpy functions.

They could install one of the scientific python stacks (e.g. anaconda) or just install packages globally with pip.

Re:Ditching Excel for Python in a legacy industry by macintux on Wednesday December 30, 2020 @08:40PM (#25588602)
Things always break over time. I have a very technical co-worker, a systems admin, with a broken Python stack on Windows. No idea what's wrong.
Re:Ditching Excel for Python in a legacy industry by fock on Thursday December 31, 2020 @06:05AM (#25591613)
so he did a chmod -w on their folder and it broke. Well, that's a feat I still have to work out!
Re:Ditching Excel for Python in a legacy industry by mch82 on Thursday January 07, 2021 @03:46PM (#25677210)
Anaconda switched its software license recently to require large companies to purchase a license, so now people must wade through the purchasing department before installation & use.
Re:Ditching Excel for Python in a legacy industry by klelatti on Wednesday December 30, 2020 @07:23PM (#25588049)
Agree completely on 1. but not sure on 2. and 4. - I think if you're using Python and need performance then you will be using Numpy etc - would be interested to hear if there are instances where this doesn't work.
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @08:30PM (#25588527)
numpy is great for vectorizable calculations, but many calcs (particularly for long-term life contingent risks, i.e. reserves), are not vectorizable except in the most simplistic cases.
Re:Ditching Excel for Python in a legacy industry by auxym on Thursday December 31, 2020 @08:51AM (#25592663)
Numba can usually speed up non-vectorizable things by JIT compiling and potentially parallelizing.

I mean, in an ideal world you'd use Julia or a Cython extension, but if you already have something in Python/numpy, numba only requires you add a decorator to your function and it gets jitted.

Re:Ditching Excel for Python in a legacy industry by klelatti on Wednesday December 30, 2020 @08:41PM (#25588612)
Thanks - sorry I'm struggling a bit - wouldn't they be vectorizable across the portfolio or across scenario for stochastic calculations. Maybe it's because of different backgrounds (mine in UK) but I'm can't recall seeing the deeply nested function calls that you're alluding to.
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @09:01PM (#25588736)
Think about the calculation of an insurance product with a Fund Value. Everything is forward recursive with respect to time. Been a while, so I might butcher some of this. It is likely that you'll want a 30 year projection, so you'll call fundValue(30 * 12)

fundValue(t+1) = if t > 0 fundValue(t) - charges(t) + intCred(t) else initialPrem

charges(t) = netAmtAtRisk(t) * costOfInsurance(t) + riderCosts(t) + policyFee(t)

netAmtAtRisk = (FaceAmt - fundValue(t))

Now think layering on decrements

surrenderMargin(t) = lapseDecrement(t) * (surrenderCharge(t) * fundValue(t))

mortalityMargin(t) = mortalityDecrement(t) * netAmtAtRisk(t)

investmentMargin(t) = (earnedRate(t) - intCred(t)) * assetBase(t)

Now think layering on calcs necessary to calculate the assetBase (e.g. reserves + required capital)...

Re:Ditching Excel for Python in a legacy industry by klelatti on Wednesday December 30, 2020 @09:11PM (#25588813)
That code looks very familiar! I see what you mean now. I don't think I've ever seen this implemented recursively though - can certainly see how this would end up being problematic if you tried to do this in Python!

ps Thanks so much for taking the time to set this out.

pps I've been working on something that implements a highly optimised version of this style of calculation - with a DSL to describe the calcs - can do 30 year cashflow projection for 1m contracts in about 1 min on quad core laptop. UK focus initially but might have wider application?

Re:Ditching Excel for Python in a legacy industry by cutler on Thursday December 31, 2020 @01:15PM (#25595305)
Clojure now has libpython which would enable you to add the recursion.
Re:Ditching Excel for Python in a legacy industry by etothepii on Wednesday December 30, 2020 @10:17PM (#25589215)
The calculations typically performed by actuaries are individually all fairly simple but in aggregate without automated testing and version control it is reckless to use them in pricing or portfolio calculations.
Re:Ditching Excel for Python in a legacy industry by harha on Thursday December 31, 2020 @03:00AM (#25590609)
For 1. I would say R is a good option. It works relatively well everywhere and has an ok IDE, lots of packages that make life easier (tidyverse). I also wouldn’t recommend python for exactly that reason.
Re:Ditching Excel for Python in a legacy industry by 1337shadow on Thursday December 31, 2020 @06:21AM (#25591669)
I thought the point was to make a web interface in Python to query some database and process to calculations on a powerful server, in which case the database and server for sure are going to be faster than excel, including the WITH RECURSIVE SQL statement, and only a browser is necessary for users which makes the solution not only multi platform but also remote-friendly. As such, your post really makes me wonder what they are trying to do at all.
Re:Ditching Excel for Python in a legacy industry by raverbashing on Thursday December 31, 2020 @04:32AM (#25591107)
Those are fair criticisms but I think under Windows, Docker+pip is the worse way of managing it

2 and 4 are surprising, it would be interesting to do a benchmark and maybe figure out the best way to do stuff in Python for your case

About 3, I suppose that's why developers should break up complex expressions (and not only in Python)

Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @05:59AM (#25591586)
Its absolutely true that an untested 1000 line python function is no better than a 1000 line untested VBA function.
Re:Ditching Excel for Python in a legacy industry by eyeball on Wednesday December 30, 2020 @11:15PM (#25589524)
Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @05:14AM (#25591345)
I have wondered about this, the lambdas and table could be of huge benefit against some of the most egregious excel mistakes but that isn't an argument for excel's use.

The problem is not one of it not being possible to do automated testing or source control in Excel. VBA is Turing complete so anything is possible, it's more one of not thinking, or understanding why, those things are important. Once you do come to think of such things as important you will quickly never use Excel for anything but the most basic calculations.

Re:Ditching Excel for Python in a legacy industry by kfk on Thursday December 31, 2020 @02:53AM (#25590575)
Hi, this is a late reply but I am actually pulling this off. Your points above all make sense but are around the desktop paradigm. If you move to the cloud paradigm not only most of the points go away but you gain a lot by having data all in one place (S3) and strict collaboration (github). Specifically the Python env problem goes away if you ask analysts to work online with notebooks (ie jupyter hub).
Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @05:06AM (#25591301)
Just because one can trace ones way through an excel spreadsheet should be of negligible comfort in the aftermath of a multi-million dollar loss.
Re:Ditching Excel for Python in a legacy industry by belorn on Thursday December 31, 2020 @05:01AM (#25591267)
The article specific mention that the environment is the browser using python notebook. In the author use case there is no docker, no pip, no window desktop for which I.T. support is managing python on client machines.

I also wonder, if I.T. support were to use docker, are they doing that for python, or would they still continue to use docker even if they move away from python?

Re:Ditching Excel for Python in a legacy industry by yufeng66 on Thursday December 31, 2020 @09:46AM (#25593086)
I am an actuary for 20 years and people have been trying to replace Excel for at least 15 of them. But Excel is not going anywhere. I think it will be even more popular with the recent introduced lamda function. Excel formulas will Turing complete and we don’t have to use VBA anymore.
Re:Ditching Excel for Python in a legacy industry by mslate on Wednesday December 30, 2020 @07:19PM (#25588014)
From an actuary's perspective: is Google Sheets ever entertained as an Excel alternative?
Re:Ditching Excel for Python in a legacy industry by will_pseudonym on Wednesday December 30, 2020 @08:22PM (#25588463)
No, for many reasons. Workbook calculation performance, advanced, complicated spreadsheet incompatibility, worse UI/keyboard shortcuts, slow UI, different language than VBA for custom functions (It isn't necessarily worse, but it's the same thing as trying to convince a department to switch from language X to Y including rewriting every application that's written in X. Also, every person you've ever hired was familiar with X, and has no experience with Y.)

R/Python/SAS etc. are a much more compelling alternative to Excel than Google Sheets (to say nothing of the actuarial modeling software packages that are used already for more rigorous/complicated problems).

If an insurance company decided to move all of their MS Office users to Google Docs/Sheets etc, my money is on the actuarial department paying for Excel out of their budget without a moment's hesitation.

Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @07:38PM (#25588152)
It's been a couple years since I've used it, and I didn't feel it was a comparable alternative. It's decent for about 80% of spreadsheet users, but the keyboard shortcuts were lacking and it was missing some functions that I rely on.

For keyboard shortcuts, most Excel power users don't use the mouse, so while it sound trivial, it's really hard to feel productive when you have to hunt around for the right button to click.

From an enterprise perspective, Excel is so entrenched it would be a 5-10 year effort to port existing spreadsheets to sheets. Practically speaking, most companies wouldn't see the benefit.

Re:Ditching Excel for Python in a legacy industry by will_pseudonym on Wednesday December 30, 2020 @08:28PM (#25588516)
> From an enterprise perspective, Excel is so entrenched it would be a 5-10 year effort to port existing spreadsheets to sheets. Practically speaking, most companies wouldn't see the benefit.

And at the end of the day, it would have worse performance than Excel both in calculation speed and _much_ worse UI. One of the reasons Excel is so much better than Sheets is speed. Insurance companies spend hundreds of thousands of dollars a year on actuaries. Even if Excel cost them $500/year/user, it would be easily worth it for actuarial departments.

Re:Ditching Excel for Python in a legacy industry by etothepii on Wednesday December 30, 2020 @10:11PM (#25589178)
The hundreds of thousands of dollars a year that insurance companies spend on actuaries is the real reason that no one will ever come off excel. The maths is not very complicated but the lack of source control and testing means each bugfix or added feature introduces another bug to fix next week or feature to add the week after.
Re:Ditching Excel for Python in a legacy industry by zinekeller on Wednesday December 30, 2020 @07:49PM (#25588237)
Used GSuite (Google Workspace?): It's fine, it is improving but lack of shortcuts even for basic tasks (I can change the font on Word with just a keyboard, try that with Docs without a mouse). Dealbreaker is the 5 million cell (not row nor column) limit, which is even lower than Microsoft's old limits (more than 15 million cells, which was increased in 2007 to you-have-a-serious-problem-if-you-somehow-fill-this-limit cells).
Re:Ditching Excel for Python in a legacy industry by andylynch on Thursday December 31, 2020 @07:26AM (#25592027)
Not to mention that if you're using Power Query, Excel's 1 million row limit doesn't apply in the workbook queries either.
Re:Ditching Excel for Python in a legacy industry by HALtheWise on Thursday December 31, 2020 @09:10AM (#25592796)
Alt+/ is the magical shortcut that makes this easy, you can simply search a font name and hit enter.
Re:Ditching Excel for Python in a legacy industry by anonymouse008 on Wednesday December 30, 2020 @07:22PM (#25588035)
Not an actuary - but I think this crosses domains: the lack of comprehensive shortcuts makes Google Sheets DOA (dead on arrival) for my uses.
Re:Ditching Excel for Python in a legacy industry by rvba on Thursday December 31, 2020 @08:38AM (#25592541)
Uploading propertiary data to a cloud is a big no.
Re:Ditching Excel for Python in a legacy industry by etothepii on Thursday December 31, 2020 @11:15AM (#25593970)
Companies are more worried about this than they probably should be.

The average enterprise network is nothing like as secure as people behave like it is.

Where do you think your email is hosted? With few exceptions I'd expect its provided by a cloud provider these days.

Re:Ditching Excel for Python in a legacy industry by maxerickson on Wednesday December 30, 2020 @07:22PM (#25588032)
Would the people doing the implementation need to be able to choose and manage dependencies? Or could they do the work inside a prepared environment (comparable to Excel in some sense).
Re:Ditching Excel for Python in a legacy industry by fock on Wednesday December 30, 2020 @07:52PM (#25588266)
that costs millions!
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @07:59PM (#25588323)
I think you are mocking me, but I'll bite.

Insurance companies are contractor heavy. They bill at $150 an hour. That's $300K annually per head. Won't take long to get a million, when you add PM overhead, information security oversight and governance, etc. Again, it shouldn't cost that much, but it does.

Re:Ditching Excel for Python in a legacy industry by deknos on Friday January 01, 2021 @04:18AM (#25601930)
from your POV, what would be an better replacement than Excel? provided it's opensource?
Re:Ditching Excel for Python in a legacy industry by davidu on Wednesday December 30, 2020 @07:33PM (#25588110)
This is the argument made against all software stack advancements. Nothing to do with industry. But when the benefits outweigh the the hurdles, change happens. And if I was starting a new insurance company (which I've considered) I'd be doing our work in code not xls, and probably python. Having RCS, Numpy, unlimited compute, unlimited storage, all gives me an advantage over my competition. :-)

As to the memoization, that is not hard to manage in Python.

Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @07:52PM (#25588262)
"As to the memoization, that is not hard to manage in Python."

Yes it is. Recursive calls for financial calculations easily go hundreds of thousands of calls deep. This is why high-end actuarial modeling software either decomposes it into a dependency graph and unrolls function calls where possible, or just "brute-forces" it by being a thin wrapper over c++, i.e. using operator overloading on ::operator().

I've seen ill-fated efforts of capable software developers attempting to unroll the recursive function calls, and ending up with 2000 line functions that are impossible to maintain.

Re:Ditching Excel for Python in a legacy industry by edmundsauto on Wednesday December 30, 2020 @11:46PM (#25589680)
I can't visualize what you mean by deep recursive calls. What are the calculations that mean you can't just use fairly bog standard python for? I didn't realize there was "big data" in accounting.
Re:Ditching Excel for Python in a legacy industry by solresol on Wednesday December 30, 2020 @08:34PM (#25588555)
Why doesn't annotating these functions with @functools.lru_cache(10000000) work?
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @09:13PM (#25588827)
First of all, let me say that I've tried it :)

Your recursion needs to "bottom-out" in order for that to work. If you don't get a stack overflow / out of memory error, you're good. But bear in mind that there will be thousands of stack frames. Before you get to time=0 (the recursive base case) in a long-term liability actuarial calc.

The recursion isn't simple like the Fibonacci sequence . It's more like:

f(t+1) = if t > 0 (f(t) + g(t)) * h(t) else initial_constant

g(t) = f(t) + q(t) - d(t)

q(t) = ....

d(t) = ....

Re:Ditching Excel for Python in a legacy industry by andi999 on Wednesday December 30, 2020 @10:17PM (#25589220)
Although at fist glance this formula is written recursively, one doesn't have to (and shouldn't) implement using recursion, does one? Just making f, g, q, d arrays and then loop over t should be good, or is there more to this formula?
Re:Ditching Excel for Python in a legacy industry by yold__ on Wednesday December 30, 2020 @10:43PM (#25589355)
Appreciate the curiosity. In this small trivial case, yes that works. But what happens when something in the logic changes?

You wind up needing to know the order of calculations since things are no longer lazily evaluated via recursion. This is a problem when you have dozens of "columns" (i.e. recursive functions or arrays as you are suggesting). Often times, the value in the array is NULL (or worse, leftover from a previous calculation). You are left to manually try and re-order the calculations, which is not trivial when there are hundreds of functions.

Excel takes care of these details for you automatically. Users program functionally and recursively (fill-down) without even thinking about it. Excel reactively updates when dependent values change (re-evaluates as necessary).

If power, speed, and scale are necessary, there are purpose-built systems (with Domain Specific Languages) which specifically solve this problem in the insurance domain (e.g. FIS Prophet, Risk Agility, AXIS, etc).

Re:Ditching Excel for Python in a legacy industry by BuuQu9hu2 on Thursday December 31, 2020 @02:09AM (#25590342)
It is common knowledge that all recursive functions can be re-written using iteration (e.g. loops). See “ Recursion versus iteration” here https://en.m.wikipedia.org/wiki/Recursion_(computer_science). The assumption that only trivial calculations can occur using iteration, or that recursion alone allows for supportable code, I believe are very flawed assumptions.
Re:Ditching Excel for Python in a legacy industry by BuuQu9hu2 on Wednesday December 30, 2020 @10:30PM (#25589292)
Um, ever heard of a “for loop”? An obvious alternative to recursion.
Re:Ditching Excel for Python in a legacy industry by Der_Einzige on Thursday December 31, 2020 @01:41AM (#25590189)
Not sure why this is being downvoted since I don't think the OP has done a good job of showing evidence that this doesn't work for recursion. Your computer almost certainly WILL have enough space for all the stack frames necessary.
Re:Ditching Excel for Python in a legacy industry by pmart123 on Wednesday December 30, 2020 @09:05PM (#25588762)
My guess is the numeric inputs would be changing significantly each call?
Re:Ditching Excel for Python in a legacy industry by klelatti on Wednesday December 30, 2020 @07:54PM (#25588283)
Agree 100% with this. Better analytics can be a key competitive advantage for insurers and modern tools / cloud offer potential to be much better than Excel.

I've been working on a product that turns JupyterLab into an IDE for life insurance calculations - Python API wrapped around an optimised C / GPU computation layer underneath, all integrated with key open source libraries.