-1

receiving columns in single column like this: abc| xyz| pqr| qqq

and there related values in row in single cell.

I want to format it like using pandas

abc xyz pqr qqq

and there related values under them

  • 2
    Please read up on [how to ask pandas questions](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – timgeb Apr 30 '20 at 05:50
  • sounds like you need to specify your delimiter, do `pd.read_csv(your_file,sep='|')` – Umar.H Apr 30 '20 at 05:59

1 Answers1

0

As Datanovice already mentioned, it looks like you need to specify the delimiter.

I added index_col and names to make the df even cleaner (guessed on your example).

  • index_col tells pandas that the first column in the csv is not the index and that it needs to create one
  • names gives you the posibility to define the column header (if they are missing in the csv).

df = pd.read_csv(your_file, sep="|", index_col=False, names=['colA', 'colB', 'colC', 'colD'])

Robin M
  • 45
  • 5