I'd like to know if there is another way instead of using apply like this:
Given this DataFrame:
df = pd.DataFrame({1: {0: 'a', 1: 'a', 2: 'a'},
2: {0: 'b', 1: 'b', 2: 'b'},
3: {0: 'c', 1: 'c', 2: 'c'}})
Using this method:
df.apply(lambda x: ' '.join(x),axis=1)
Result:
s = pd.Series({0: 'a b c', 1: 'a b c', 2: 'a b c'})
Is there another way of doing this? I have a DataFrame with a lot of rows and I am trying to find the fastest way of doing such task.
Thank you!