I would like to ask a question, which is an extension in this thread:
Select rows from a DataFrame based on the values ββin a column in pandas .
The code from this thread is shown below:
import pandas as pd import numpy as np df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(), 'B': 'one one two three two two one three'.split(), 'C': np.arange(8), 'D': np.arange(8) * 2}) print(df)
This will produce the following result:
ABCD 7 foo three 7 14
Based on the code above, how can I return a single βvalueβ, not a string. That is, how can I return the value '7' or the value 'foo' as opposed to the whole line?
source share