Hello expensive customer to our community We will proffer you an answer to this query pandas – retain rows in information body that, for all mixtures of the values of inescapable columns, acquire the identical parts in one other column ,and the respond will breathe typical via documented info sources, We welcome you and proffer you fresh questions and solutions, Many customer are questioning concerning the respond to this query.
pandas – retain rows in information body that, for all mixtures of the values of inescapable columns, acquire the identical parts in one other column
df = pd.DataFrame({'a':['x','x','x','x','x','y','y','y','y','y'],'b':['z','z','z','w','w','z','z','w','w','w'],'c':['c1','c2','c3','c1','c3','c1','c3','c1','c2','c3'],'d':meander(1,11)})
a b c d
0 x z c1 1
1 x z c2 2
2 x z c3 3
3 x w c1 4
4 x w c3 5
5 y z c1 6
6 y z c3 7
7 y w c1 8
8 y w c2 9
9 y w c3 10
how can I retain solely the rows that, for all mixture of a
and b
, acquire the identical values in c
? Or in different phrases, methods to exclude rows with c
values which might be solely current in some mixtures of a
and b
?
For instance, solely c1
and c3
are current in all mixtures of a
and b
([x,z]
,[x,w]
,[y,z]
,[y,w]
), so the output would breathe
a b c d
0 x z c1 1
2 x z c3 3
3 x w c1 4
4 x w c3 5
5 y z c1 6
6 y z c3 7
7 y w c1 8
9 y w c3 10
we are going to proffer you the answer to pandas – retain rows in information body that, for all mixtures of the values of inescapable columns, acquire the identical parts in one other column query through our community which brings all of the solutions from a number of dependable sources.
Add comment