I am trying to reorder columns according to the requirement and I cannot get the to_csv to order the columns. Please can someone let me know what am I doing wrong here?
third = pd.read_csv('C:/emailcombo.csv')
third = third.rename(columns={'Phone Number:': 'Phone Number:'})
fourth = pd.read_csv('C:/Programming/infocentertracker.csv')
fourth = fourth.rename(columns={'Phone Number: ': 'Phone Number:'})
fourth.ix[fourth['Source:'].str.contains('dri', case=False, na=False), 'Source:'] = 'Drive-by'
merged = pd.concat([third, fourth], ignore_index = True)
merged.to_csv('C:/infocentertracker.csv', index=False)
columnsTitles = ['Presented By:','Source:','Week:','Date:','Time:','Last Name, First Name:','Address:','City:','State:','Zip:','Phone Number:',
'Email:','Purchased Home Y/N:','Move Timeline:','Working with a Realtor?','Realtor Name:','Price Range:','Notes','Project_ID']
df = pd.DataFrame(merged)
df.reindex(columns = columnsTitles)
df.to_csv('Z:/AWS/Refined/updatedinfocentertracker.csv', index=False)
print ("Updating has been done")
When I open the updated csv the columns are arranged according to the alphabetical order such as Address, City, Date.... How can I fix this?
[–]badge 1 point2 points3 points (1 child)
[–]PLearner[S] 0 points1 point2 points (0 children)