A DataFrame usually contains multiple rows (and columns).
So if you ask whether particular column (say xx) has some value:
df.xx == 20
you will get a boolean Series with:
- indices copied from df,
- value stating whether xx column in this row == 20.
So I assume that you question about particular value in a given column
should actually be expressed as: Does any element in this column
have particular value?.
You can check it with any() function:
(df.xx == 22).any()
This time the result will be a single boolean.
In your case you can write:
if (df.column_name == '1-5').any():
result = df.Minutes
Of course it is open to question what if not?
Do you want another column in result variable?
Another approach is to set the column name in some variable,
say src_col, based on some your logic.
Then, having this variable set, you can refer to the required column as:
result = df[src_col]
Note that this time:
- the column name is between brackets,
- but it is not surrounded with apostrophes,
so the target column name is expressed by the value of this variable.
And a remark about the comment by Chris90:
If you write df.loc[df['column_name'] == '1-5','Minutes']
you will get a single value from:
- row containing 1-5 (string) in column_name,
- Minutes column.
But you wrote that you wanted all values from this column.