By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,583 Members | 3,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,583 IT Pros & Developers. It's quick & easy.

Nested loop based number of filtered rows

P: 1
My Csv File looks like below
Territory NoOfCustomer
D00060 10
D00061 20
D00065 70
D00067 90

I have to create a Unique Id based on Number of NoOfCustomer like If NoOfCustomer <=50
then I have to create 10 different Unique ID for Territory D00060 and 10 different Unique ID for Territory D00061.

Here I read my csv file in pandas like

csv_file = 'cust_valid.csv'

Filtered having customers <= 50

low_dense = df['NoOfCustomer'] <=50

And then iterted low_dense like
This part will only iterate the filterd zip_codes

for index,row in Highly_low.iterrows():
for loop in row:

Here I wanna a write to another CSV file with columns like

Territory NoOfCustomers UniqueId
D00060 10 0001ASDDF900f
D00060 10 qwdfeed0909jkl
D00060 10 lhjkhj90090kllkm
D00060 10 jhjkhjk0909090
Oct 18 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.