Nested loop based number of filtered rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepkumarbe
    New Member
    • Oct 2018
    • 1

    Nested loop based number of filtered rows

    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 '
    df=pd.read_csv( csv_file,delimi ter="|")

    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.iter rows():
    for loop in row:
    print('S')

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

    Territory NoOfCustomers UniqueId
    D00060 10 0001ASDDF900f
    D00060 10 qwdfeed0909jkl
    D00060 10 lhjkhj90090kllk m
    D00060 10 jhjkhjk0909090
Working...