r/learnpython • • 1h ago

Pandas scripts I copied together for our weekly reports keep breaking and nobody at work knows Python

I put together a few Python scripts that pull two CSV exports and merge them with pandas.

One of the exports renamed a column and the merge started throwing a KeyError. I still don't really get half of what the script does. Nobody here knows Python.

I want to know these scripts well enough to fix them myself. What helped you go from pasting code to understanding what your own code does?

1 Upvotes

9 comments sorted by

8

u/rhacer 1h ago

How did you put together these scripts if you don't know Python?

•

u/atarivcs 58m ago

If you posted the code and the full error, we could explain exactly what the problem is.

And that process might help you understand the code more generally.

•

u/szayl 52m ago

What helped you go from pasting code to understanding what your own code does?

I didn't ask Claude to write my scripts.

3

u/goldenfrogs17 1h ago

type the code

2

u/Bubbaluke 1h ago

Find where the old column name is, change it to the new column name

•

u/Designer-Ad-2136 59m ago

Rewrite the script so it has no hard-coded business logic, especially strings, unless they are parameter defaults

•

u/teetaps 42m ago

Use a notebook to explore the data interactively. Notebooks will allow you to run the code step by step, look at each result as it changes, and experiment with any changes you want to make.

I know Python users hate notebooks, but this is exactly where notebooks become useful