Create column for str contain in pandas

+2 votes
With below code I am able to create dataframe

VAT = comm[comm['Particulars'].str.contains("comm|Britain", case=False)==True]

 VAT

 But I want to create column

below code does not work

comm['VAT'] = comm[comm['Particulars'].str.contains("comm|Britain", case=False)==True]

 comm

 Can you provide proper code ?
Jan 5, 2020 in Python by Juzar
• 140 points
539 views

1 answer to this question.

0 votes
Hi Juzar

So if I am not wrong you have a dataframe called COMM from which you are filtering out the column particulars. These filtered values became another dataframe called VAT. But you do not want them as another dataframe, you want it as a column?

What you can do is, append the COMM dataframe with VAT. VAT will just become another column in COMM.

Hope it helps :)
answered Jan 6, 2020 by Kalgi
• 52,360 points

Related Questions In Python

0 votes
1 answer

How can I reformat value_counts() analysis in Pandas for large number of columns?

If I were you, I'd do it ...READ MORE

answered Apr 17, 2018 in Python by anonymous
6,436 views
0 votes
1 answer

Reformat value_counts() analysis in Pandas for large number of columns

I'd do it this way: In [83]: df.drop('id',1).apply(lambda ...READ MORE

answered Sep 25, 2018 in Python by Priyaj
• 58,090 points
1,642 views
0 votes
1 answer
0 votes
1 answer

How to print just one column in pandas?

You can use the header to print ...READ MORE

answered Apr 4, 2019 in Python by TIna
10,319 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,023 views
0 votes
1 answer
+7 votes
8 answers

Difference for string comparison in Python: 'is' vs. ==

If we use "==" means both variables ...READ MORE

answered Sep 3, 2018 in Python by Parul Raheja
1,736 views
0 votes
1 answer

API key for Copyleaks Python sdk

Your API-KEY is available at your dashboard ...READ MORE

answered Aug 5, 2019 in Python by Kalgi
• 52,360 points
698 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