I'm working on creating a Python generated report that uses Pandas DataFrames. Currently I am using the DataFrame.to_string()
method. However this writes to the file as a string. Is there a way for me to achieve this while keeping it as a table so I can use table formating.
Code:
SEMorgkeys = client.domain_organic(url, database = "us", display_limit = 10, export_columns=["Ph,Pp,Pd,Nq,Cp,Ur,Tr"])
org_df = pd.DataFrame(SEMorgkeys)
f = open(name, 'w')
f.write("\nOrganic:\n")
f.write(org_df.to_string(index=False,justify="left"))
f.close()
Current Printout (as string):
CPC Keyword Position Difference Previous Position Search Volume Traffic (%) Url
75.92 small business factoring 0 1 210 11.69 https://www..com/small-business-f...
80.19 factoring company 0 8 1600 5.72 https://www..com/factoring-vs-ban...