Reputation: 2158
I am trying to remove the rows when column C has stand alone data value set to be ",". The code below is removing all the rows that contains ',', how do I just remove value =',' and not delete anything else?
df2 = pd.DataFrame(dict(A=[1,2,3,4,5,6], C=["Doe, John",",","Driver,A","Matt,", ",",","]))
df2
df2[~df2.C.str.contains(",")] # removes everything
Input:
A C
1 Doe, John
2 ,
3 Driver,A
4 Matt,
5 ,
6 ,
Output Needed:
A C
1 Doe, John
3 Driver,A
4 Matt,
Upvotes: 0
Views: 40
Reputation: 520
Given you don't want the exact character ',' you can do:
df2[df2.C != ',']
Upvotes: 1