I used the following to obtain state using zipcode
from uszipcode import SearchEngine
engine = SearchEngine()
zipcode = engine.by_zipcode(ZIPCODE)
**st** = print(zipcode.state)
Now I am trying to insert state into data frame df2:
- I can do it manually such as:
df2.assign(STATE = 'Florida')
*Column name is STATE
However, new data will used with this scrip so I need to use a variable. How can I do that?
This is my unsuccessful shot:
df2.assign(STATE = **st**)