ENH: Adding argmin, argmax to Series and DataFrame. #286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Wess,
Pull request to let you know that i added argmin and argmax methods to Series and DataFrame.
I also included unit tests. It`s not that much work/code, but anyway an interesting enhancement i think.
some examples:
In [23]: s
Out[23]:
a 0.80015881463
b 0.983432892599
c 0.965122593504
d 0.81910825442
e 0.726239458506
Name: None, Length: 5
In [24]: s.argmin()
Out[24]: 'e'
In [25]: s[s.argmax()] == s.max()
Out[25]: True
In [26]: df
Out[26]:
A B C D E
one two three
a b 10 -0.6155 1.237 1.371 1.24 -0.7725
p q 20 1.14 -0.3743 0.5251 0.2426 1.81
x y 30 0.6626 2.004 -0.01327 1.587 0.3524
In [27]: df.argmax(axis=0)
Out[27]:
A ('p', 'q', 20)
B ('x', 'y', 30)
C ('a', 'b', 10)
D ('x', 'y', 30)
E ('p', 'q', 20)
Name: None, Length: 5
In [28]: df.argmin(axis=1)
Out[28]:
a b 10 E
p q 20 B
x y 30 C
Name: None, Length: 3
What do you think?
Wouter