What is the best way to apply a function over the index of a Pandas DataFrame? Currently I am using this verbose approach:
DataFrame
pd.DataFrame({\"Month\":
Assuming that you want to make a column in you're current DataFrame by applying your function "foo" to the index. You could write...
df['Month'] = df.index.map(foo)
To generate the series alone you could instead do ...
pd.Series({x: foo(x) for x in foo.index})