separate a .txt file into two columns using pandas

I have a .txt file, without header. I am going to separate into two column with header X and Y that is ordered like this:

enter image description here

I have read text file into pandas:

How can I have data frame with two column and header X and Y?

enter image description here

>Solution :

df = pd.read_csv(
  delim_whitespace=True,  # any whitespace separates data
  names=["x", "y"],  # column names
  index_col=False,  # no index

ought to do the trick.

Leave a Reply