The way you were trying to do it, would be something like this:
df[c] = df[c].str.rstrip(',')
rstrip(',')
will remove comma just from the end of the string.
strip(',')
will remove it from start and end positions both.
The above will replace the text. It will not let you drop the rows from the dataframe. So you should do below:
Use str.endswith
:
df[~df['col'].str.endswith(',')]
Consider below df:
In [1547]: df
Out[1547]:
date id value rolling_mean col
0 2016-08-28 A 1 nan a,
1 2016-08-28 B 1 nan b
2 2016-08-29 C 2 nan c,
3 2016-09-02 B 0 0.50 d
4 2016-09-03 A 3 2.00 ee,ff
5 2016-09-06 C 1 1.50 gg,
6 2017-01-15 B 2 1.00 i,
7 2017-01-18 C 3 2.00 j
8 2017-01-18 A 2 2.50 k,
In [1548]: df = df[~df['col'].str.endswith(',')]
In [1549]: df
Out[1549]:
date id value rolling_mean col
1 2016-08-28 B 1 nan b
3 2016-09-02 B 0 0.50 d
4 2016-09-03 A 3 2.00 ee,ff
7 2017-01-18 C 3 2.00 j