This is related to one of the questions that was trying to respond to. Id: 61801654
Dataset:
Q GDP
2008q3 14891.6
2008q4 14577.0
2009q1 14375.0
2009q2 14355.6
The idea was to get the value of Q for minm value of GDP. The correct answer was:
df.loc[df['GDP'].idxmin()]['Q']
Output:
2009q2
<class 'str'>
What I thought could also be the answer is this:
df.loc[df['GDP'] == df['GDP'].min()]['Q']
However, the output with this is:
3 2009q2
<class 'pandas.core.series.Series'>
For reference, 3 is the index of the dataframe that I created using the read_clipboard(sep='\s\s+') function:
df = pd.read_clipboard(sep='\s\s+')
Q GDP
0 2008q3 14891.6
1 2008q4 14577.0
2 2009q1 14375.0
3 2009q2 14355.6
I want to understand why is df.loc[df['GDP'] == df['GDP'].min()]['Q']
returning a series while df.loc[df['GDP'].idxmin()]['Q']
is just returning a string value.
Could not find a similar problem already been answered. My apologies if its a duplicate.