-1

I have the following code. When i save it. The headers of columns don't save. Could u please guide me?

import numpy as np
import pandas as pd

A = np.random.randint(0, 10, size=36).reshape(6, 6)

df = pd.DataFrame(A,  columns=['one', 'two', 'three','four','five','six'])
np.savetxt("/home/dataset/test.csv",df, delimiter=",")
Talia
  • 2,153
  • 4
  • 12
  • 28

1 Answers1

1

Use the built-in pandas function for this:

df.to_csv("your_file_path_here")