Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My CSV file

Python
ZIP_CODE   POPULATION
00601      700 
00606      500
11224      12000
23469      20000


I will create a Unique ID based on the population, like If Population <= 1000 then I have to create 10 Unique Id for Zip_code 00601 and 10 different Unique ID for zip_code 00606

What I have tried:

Below is what I have tried

pop_by_zip = r'population_census.csv'

df=pd.read_csv(pop_by_zip,delimiter="|")

Highly_low =df['Population'] <=1000


Here I want to Iterate over each rows having Population <=1000 and have to create 10 Unique Id for each Zip code. I am kind of stuck in looping here, help me out here

And I have to write an output file with below columns

Python
Zip_Code  Population   UniqueId
00601     700          00000asdf98
00606     500          00000fgsshf98
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900