-1
$\begingroup$

this question has been ask couple of times but none of the answer is working for that what I want.

For example I have this excel Dokument:

Numbers  Names  Address 
1        Ben    Street1
2        Anna   Street2
3        Tom    Street3

Now I want to store only the column Names into one string:

string_text = "Ben Anna Tom"
print(string_text)-> Ben Anna Tom

I tried this out:

string_text = str(df['Names'].values)
print (text)

and I get:

['Ben' 
'Anna' 
'Tom']

Is there any option I can get really only the value of each cell and concatenate them together without the apostrophes in between?

$\endgroup$
1
$\begingroup$

If you are looking to create a list then you can use:

list(df['Names'].values[1:])

If you are looking to create a long string use join (you can of course choose any delimiter you like):

' '.join(df['Names'].values[1:])
$\endgroup$
  • $\begingroup$ if I do so, I will get a String where every char is separated and I still have the apostrophes. $\endgroup$ – Loretta Nov 25 '20 at 9:35
  • $\begingroup$ and if I use to_string its truncates the strings of the cells $\endgroup$ – Loretta Nov 25 '20 at 10:01

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