-2
$\begingroup$

I got the nice plot but I want to export the data of x and y in column to excel sheet

import numpy as np
import matplotlib.pyplot as plt

for i, (f, g) in enumerate(zip(frequencies.T, gv_norm.T)):
   plt.plot(f, g 'o')
plt.show()
print (" Frequency:  %s     Group : %s " %(f, g))

I want to export the data frequency and group to excel in column. How to do it?

$\endgroup$
2
  • $\begingroup$ Use an external library. Pandas is the most notorious one. $\endgroup$
    – IMCoins
    Aug 5, 2019 at 7:29
  • $\begingroup$ Please don't use images for code/text in your question. if you just print the two columns separated by a comma you can import the resulting text file as CSV in excel. $\endgroup$
    – Erwan
    Aug 5, 2019 at 8:42

1 Answer 1

0
$\begingroup$

You can use the Pandas library like:

import pandas as pd
dataTmp = {
    "col1": frequencies.T
    "col2": gv_norm.T
}
data = pd.DataFrame(dataTmp)
data.to_csv("csvName.csv", index=False, sep=";")
$\endgroup$
1
  • $\begingroup$ I am getting this errorr. aise ValueError('If using all scalar values, you must pass' ValueError: If using all scalar values, you must pass an index $\endgroup$ Aug 5, 2019 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.