R Vector syntax in Python / Pandas

Viewed 77

I've created the following code in R.

data=c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width")
  terms<- paste(data, collapse='+')

and this gives;

"Sepal.Length+Sepal.Width+Petal.Length+Petal.Width"

Is there a way of doing something similar in Python / Pandas?

1 Answers

use join:

d = ["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"]
x = '+'.join(d)
print(x)

output:

Sepal.Length+Sepal.Width+Petal.Length+Petal.Width
Related