Your code (below) is too garbled to be able to read
On Monday, May 2, 2016 at 12:00:59 AM UTC+5:30, David Shi wrote:
> Hello, I am back. Thank you very much for your positive response.
> I am trying to use Pandas apply to execute a lookup function, so that we can
> put abbreviation in a new column, in accordance to a state name in another
> column.
> Does anyone knows how to make this to work?
> Regards.DavidLook up functionstate_to_code = {"VERMONT": "VT", "GEORGIA":
> "GA", "IOWA": "IA"}#table['moa_state_name'] = map(lambda x: x.upper(),
> table['moa_state_name'])def convert_state(row): abbrev1 =
> state_to_code(table['moa_state_name']) #'aatest' if abbrev1:
> return abbrev1 ##state_to_code[abbrev[0]] return np.nan#print
> convert_state(table['moa_state_name'])
> table.insert(0, "abbrev", np.nan)
> table['abbrev'] = table.apply(convert_state, axis=1)print
> state_to_code['ARKANSAS']
--
https://mail.python.org/mailman/listinfo/python-list