.join() method is used for what purpose in Python?

0 votes
May 14, 2019 in Python by Shabnam
• 920 points
82 views

1 answer to this question.

0 votes

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
answered May 14, 2019 by Taj
• 1,040 points

Related Questions In Python

0 votes
1 answer

What is the patterns package in python used for?

Pattern is a web mining tool in ...READ MORE

answered Jul 31, 2019 in Python by Mohammad
• 3,210 points
47 views
0 votes
0 answers

What is the purpose of fit method in sklearn module in python?

I am new to machine learning. I ...READ MORE

Jul 5, 2019 in Python by Waseem
• 4,520 points
235 views
0 votes
1 answer

What is the flow control for “continue” in python?

This is the way "continue" statement works! You ...READ MORE

answered Jul 16, 2018 in Python by Priyaj
• 57,530 points
83 views
+1 vote
1 answer

What is the correct order to learn concepts in Python for machine learning?

Machine Learning is a vast domain. It ...READ MORE

answered Jul 25, 2018 in Python by Anmol
• 3,680 points
115 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 745 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

assert keyword in python is used for what purpose?

The assert keyword is used while debugging ...READ MORE

answered May 24, 2019 in Python by Taj
• 1,040 points
238 views
0 votes
2 answers

In Python, what is difference between Array and List?

Python does not have native array data ...READ MORE

answered Mar 19 in Python by chirag
• 180 points
34,654 views