Question

A have a data frame with State Abbreviation and Full State Name.

How do I take a state abbreviation and lookup the Full Sate Name? Its so simple but I just can't figure it out.

stateDF = pandas.read_csv("c:\\states.csv", index_col=0)

targetState = "AL"

fullName = stateDF.ix(targetState,"Full Name")
Was it helpful?

Solution

How about:

stateDF[stateDF['abbreviation_column'] == targetState]['Full Name']

Where 'abbreviation_column' is the name of the column where the abbreviation resides. This will find all rows that have the targetState variable in the abbreviation column and return only the Full_Name value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top