Answers for "pandas pull value from column"

0

pandas pull value from column

# Find all rows where ColumnA is stringA and give me columnC (Returns a list)
df[df['columnA'] == 'stringA']['columnC']

# Same logic but give me the value at columnC (Returns the first value)
df[df['columnA'] == 'stringA']['columnC'].iat[0]

# multiple arguments (parenthesis are required)
df[(df['columnA'] == 'stringA') & (df['columnB'] >= 53)]['columnC'].iat[0]
Posted by: Guest on July-15-2021

Code answers related to "pandas pull value from column"

Python Answers by Framework

Browse Popular Code Answers by Language