In mapping a pandas DataFrame's numeric fips index to state name, I currently have to do this:
state['state'] = pd.Series(state.index).apply(
lambda x: us.states.lookup(str(x).zfill(2)).name).tolist()
There are a couple things going on here that could be other issues*, but might also be nice to have the vectorization built-in for pandas. e.g. I'd like to be able to just do:
state['state'] = us.states.lookup(state.index)
* This one was verbose because things like us.states.lookup(1) and us.states.lookup('1') fail.
In mapping a pandas DataFrame's numeric fips index to state name, I currently have to do this:
There are a couple things going on here that could be other issues*, but might also be nice to have the vectorization built-in for pandas. e.g. I'd like to be able to just do:
state['state'] = us.states.lookup(state.index)* This one was verbose because things like
us.states.lookup(1)andus.states.lookup('1')fail.