I have CSV file Sales_In.csv and DataFrame is:
Sales_Region Dollar_value
East 500
west 500
south 500
North 2000
I am Using pandas
import pandas as pd
import UUID
df= pd.read_csv('Sales_In.csv')
low_sales =df[(df['Dollar_value'] >=500) & (df['Dollar_value']<=1000)]
for index,row in low_sales.iterrows():
for loop in range(10):
print(uuid.uuid1().hex[:8],"REP"+str(uuid.uuid4().hex[:9]),row['Sales_Region'])
Above code gives me the output like below
279418fe HCP6eacac48a East
279418ff HCP6fb7d0ec2 East
27941900 HCP21cb84de3 East
27941901 HCP9b6a34bf0 East
27941902 HCP6aa9f0e20 East
27941903 HCP6fa5e3201 East
27941904 HCPabecf8c42 East
27941905 HCP0922c8acc East
27941906 HCPea9e91d7c East
27941907 HCP95f8dbfb9 East
I wanna write this to csv file with headers like below
CUS_KEY Unique Key Sales_Region
279418fe HCP6eacac48a East
279418ff HCP6fb7d0ec2 East
27941900 HCP21cb84de3 East
...................
I am new to python I am kind of stuck in this help me out Thanks!
Highly_lowcome from? And if you want to write to csv. Use thepd.DataFrame.to_csv()func!print(uuid.uuid1().hex[:8],"REP"+str(uuid.uuid4().hex[:9]),row['Sales_Region'][['CUS_KEY', 'Unique Key ' , 'Sales_Region']])