I have this statement:
Which brand or brands offer two different types of fuel?
I have managed to display the following list:
make fuel-type size
0 alfa-romero gas 3
1 audi gas 7
2 bmw gas 8
3 chevrolet gas 3
4 dodge gas 9
5 honda gas 13
6 isuzu gas 4
7 jaguar gas 3
8 mazda diesel 2
9 mazda gas 15
In principle, it shows me the results well: mazda has two types of fuels and the others do not. But how can I obtain only the Mazda brand, which is the one that fulfills the statement?
I show the table with this code;
data.groupby(['make','fuel-type'], as_index=False).size()
Hello Dear Albarracín, a pleasure to greet you
it could be with the method
nunique()
, the way your data is organized it will count the non-unique data in the "fuel-type" columnit gives me this result
You will see that the occurrence is "mazda" is 2. then it is filter by content greater than or equal to 2.
If you wanted to only see the ones with the highest occurrence, this would be the result.
I hope I have contributed to the solution of the problem,
Cheers