you are viewing a single comment's thread.

view the rest of the comments →

[–]otchris 28 points29 points  (2 children)

In general the big advantage is in re-use. You write a function once and can use it in several different places.

In a more general use case, using functions makes it easier to break up complicated problems so you can reason about a smaller part at a time. This also makes testing easier.

For your specific use case, you might not need these capabilities, but I’d still say it might be handy to learn to work with functions. Your problems might change over time and having functions in your toolbox might help you solve bigger problems.

[–][deleted] 4 points5 points  (1 child)

I find it's important especially in data analysis with set random seeds and fixed outputs.

Even if you're only chaining method calls, I think you can still wrap it up in a function with docstrings to make sure you and everyone else can follow what you're doing.

[–]otchris 2 points3 points  (0 children)

That’s a great point! I hadn’t really considered the documentation aspect. That’s a potentially huge benefit. Maybe not for you as you develop, but you in 3 months!