I have been using indexes more and more if you do essentially series based operations but you need to re-associate the results back. It enables you to avoid using dataframes as inputs to your data transformations.
i used to write a lot of functions which went like this:
def convert_price(price_frame:pd.DataFrame) -> pd.DataFrame:
price_frame["new_price"] = np.exp(price_frame)
return price_frame
and i came back to these functions, and i was always like. hmm what needs to be in the price frame. which columns etc. Also it mutates the state of the data framewhile i now write functions like
def convert_price(price:pd.Series) -> pd.Series:
return np.exp(price)
However what is good as well you can treat the series as a single dimensional array and do operations on it. Its not a perfect example since im not using the ids haha but you might see what i mean :D