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
754 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,350 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,693 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,020 points
1,985 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,818 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
+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
2,439 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,350 points
993 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