I need to read this csv file with Panda, perform some process on it and write the rest 10% of the data to another sheet.
Given this solution (https://stackoverflow.com/a/55763598/3373710), I want to do a process on the rest of store_data after taking out the 10% rows, however, elif condition prints the same rows of the original file, how can I fix my condition to skip the 10% rows?
store_data = pd.read_csv("heart_disease.csv")
with open("out1.csv","w") as outfile:
outcsv = csv.writer(outfile)
for i, row in store_data.iterrows():
if not i % 10: #write 10% of the file to another file
outcsv.writerow(row)
elif i % 10: #I need to do some process on the rest of the file
store_data = store_data.applymap(str)
Aucun commentaire:
Enregistrer un commentaire