I have the following DataFrame:
d2=
cod consul
0 231 890201
1 345 890202
2 611 890203
3 592 890303
4 598 890203
5 211 NaN
6 355 890202
7 711 NaN
8 592 890703
9 598 890501
I require a filter that allows me to extract the rows whose values in the 'consul' column end in '03'. It should be noted that all data is string type.
In my example the filter I should get would be:
filtro=
cod consul
2 611 890203
3 592 890303
4 598 890203
8 592 890703
I appreciate your help.
If your column is of type integer, for this specific case, the simplest thing is to obtain the remainder of the integer division by 100 (modulo 100), which will give us the value of the last two digits, which we can use to create a boolean mask:
If your column contains Python strings you can use
pandas.Series.str.endswith
: