Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert dataframe row into string of values without column indexes in python

I have a dataframe row and want to get it as a string of just the values, no columns.

col1 | col2 | col3
-----------------
1    | 2    | 3
x    | y    | z

I'd like to be able to select just one row and have it as a string like:

'1','2','3'

But I keep getting the column names still in there, or lots of other values like:

"['1' '2'\n '3']"
like image 757
Dick McManus Avatar asked Dec 07 '22 12:12

Dick McManus


1 Answers

just use

df.iloc[1,:].to_string(header=False, index=False)
  1. header = False --> don't include column names in the output string

  2. index = False --> don't include row index in the output string

like image 197
Magho Avatar answered May 31 '23 23:05

Magho