My code runs through XML files and parses certain data. I'm using pandas to organize, dataframe, and write to CSV which looks like:
data = {"Name":inv_names, "Publication Date":date_pub, "Document Number":doc_num, "Patcit":name_citation, "Npatcit":data2, "Country":data3, "MainClass":data13}
df = pd.concat([df, pd.DataFrame(data)])
with open("./output.csv", "a", encoding = 'utf-8') as f:
df.to_csv(f, index = False)
This prints to the CSV file like:
Country Document Number MainClass Name Npatcit Patcit Publication Date
All I really want to do is re-order this data like:
Name Publication Date Document Number ..... (just like the order given by data above)
Might be a simple case but I've tried things like df.sort_values()
by different types but nothing seems to work.