join method is used for what purpose in Python

0 votes
May 14, 2019 in Python by Shabnam
• 930 points
1,108 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,080 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,230 points
723 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
• 58,020 points
764 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 Abhi
• 3,720 points
1,058 views
+1 vote
1 answer

What is the function for Factorial in Python

Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE

answered Aug 21, 2018 in Python by Priyaj
• 58,020 points

edited Aug 21, 2018 by Omkar 1,348 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

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

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
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,080 points
3,997 views
+1 vote
4 answers

In Python, what is difference between Array and List?

Lists and arrays are used in Python ...READ MORE

answered Mar 15, 2019 in Python by Taj
• 1,080 points

edited Mar 18, 2019 by Omkar 152,789 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP