Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a search by fips would ideal. #75

Open
BudBernhard opened this issue Jun 7, 2023 · 0 comments
Open

Adding a search by fips would ideal. #75

BudBernhard opened this issue Jun 7, 2023 · 0 comments

Comments

@BudBernhard
Copy link

Queried CHAT GPT chat.openai, "I have a data set with census fips identifiers, i'd like to find out the zip code of the fips for a python df" and then "instead of printing the zip code append it the row that the fips was in"

from uszipcode import SearchEngine

# Create a search object
search = SearchEngine()

# Assuming your DataFrame is named 'df' and the FIPS identifiers are in a column named 'fips'
df['zip_code'] = None  # Create a new column to store the zip codes

for index, row in df.iterrows():
    fips = row['fips']
    result = search.by_county_fips(fips)

    if result:
        zip_code = result[0].zipcode
        df.at[index, 'zip_code'] = zip_code  # Assign the zip code to the 'zip_code' column in the current row
    else:
        df.at[index, 'zip_code'] = 'Not Found'  # If no zip code is found, assign a placeholder value

# Print the updated DataFrame
print(df)

Nice try AI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant