> result_dataFrame['yearOverYearMax'] = year_dataFrame.groupby('partId')['unitCost'].max()
> And big productivity booster on code entry.
Try reducing the DRY violations and you might have to write less. Almost the entire right side of the first two lines is repeated and third line is only that long because it has to recover the results from the map instead of using local variables.
While tools like boxing gloves reduce the damage your face takes it is usually better to just try and stop hitting yourself first.
There's DRY, then there's premature optimization.
I am unsure about what could possibly be better about them? Twice the chance to misspell one of the string constants? Twice the time to write the code, which in this case seems to be the big blocker? Twice the code to update in case any of it has to change? Twice the complexity per line of code?
In any case, DRY is just an optimization theme. And optimizing for understanding/intent is a higher priority for me. Sometimes they intersect, sometimes not.
It was a bit of an emergency and I was figuring Pandas out at the same time. The un-dry structure is handy for me because I can quickly tweak individual things since as a company we are still figuring out what is needed in the report.
I was writing a parser for URL query strings (?these=things&key=value) and at one point Copilot suggested
return [decodeURIComponent(key), decodeURIComponent(value)];
and until I saw that I didn't even know that percent encoded text in URLs is something I needed to be thinking about.
So github copilot is pretty neat I entered this code:
Then when I put in result_dataFrame['yearOverYearChange'] Copilot gave me So it's a fancy context aware autocomplete. And big productivity booster on code entry.