I have a dataset that looks something like this:
Column A Column B Column C
1 D 40 hex
2 E 50 def
3 E 70 foo
4 D 60 bar
5 E 90 key
and I want to sort the dataframe by the values in column A, keeping the other values in the associated rows together to get something like this:
Column A Column B Column C
1 D 40 hex
4 D 60 bar
3 E 70 foo
2 E 50 def
5 E 90 key
or at least select a smaller dataframe with just D or E value rows like this:
Column A Column B Column C
3 E 70 foo
2 E 50 def
5 E 90 key
I was looking into using the df.loc function, but I do not know what index values the “D” rows are at (and they are less that ~5% of over 13,000 rows). Is there a multi-indexing way doing this? Or should I be using a different function entirely?
etruhart314 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.