join() method is used to concatenate or join all the iterables into one string, and this string must be specified as the separator.
Syntax:
>>string.join(iterable)
Example:
Lets join a list with ','.
>>mylist = ['1', '2', '3', '4', '5']
>>S = ","
#joins elements of mylist with S and store it in string S
>>S = S.join(mylist)
>>print(S)
1,2,3,4,5
Now let's join two dataframes using join() method
>>import numpy as np
>>import pandas as pd
>>df1 = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3']})
>>df2 = pd.DataFrame({'B': ['B0', 'B1', 'B2', 'B3']})
>>df1.join(df2)
|
A |
B |
0 |
A0 |
B0 |
1 |
A1 |
B1 |
2 |
A2 |
B2 |
3 |
A3 |
B3 |