Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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]
 
PREVIOUS NEXT
Tagged: #pandas #pull #column
ADD COMMENT
Topic
Name
3+5 =