r/learnpython • u/Deep-Ostrich9298 • 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?
0
Upvotes
13
u/rhacer 1h ago
How did you put together these scripts if you don't know Python?
8
u/atarivcs 1h 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.
6
u/szayl 1h ago
I didn't ask Claude to write my scripts.
3
u/goldenfrogs17 1h ago
type the code
3
u/Bubbaluke 1h ago
Find where the old column name is, change it to the new column name
3
u/teetaps 1h 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
•
u/shorelined 38m ago
How can we help fix code that we can't read?
0
u/Designer-Ad-2136 1h ago
Rewrite the script so it has no hard-coded business logic, especially strings, unless they are parameter defaults