Search
 
SCRIPT & CODE EXAMPLE
 

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]
Comment

PREVIOUS NEXT
Code Example
Python :: ImportError: sys.meta_path is None, Python is likely shutting down 
Python :: NumPy flipud Syntax 
Python :: write a python program to find the second largest number in a list 
Python :: python lock file 
Python :: fixed size list in python 
Python :: remove element from pack tkinter 
Python :: python while variable is not 
Python :: selenium webdriver without opening browser 
Python :: support vector machine example 
Python :: pandas merge sort columns 
Python :: private attributes python 
Python :: numpy unique axis 
Python :: django run manage.py from python 
Python :: how to add legend on side of the chart python 
Python :: ** in python 
Python :: DIF_GCD solution 
Python :: cascade models in django 
Python :: change every element of list python with map 
Python :: how to concatenate two strings in python 
Python :: how to draw dendrogram in python 
Python :: python any in string 
Python :: python reply to email 
Python :: Changing default fonts in matploitlibrc file 
Python :: how to delete a column in pandas dataframe 
Python :: use latest file on aws s3 bucket python 
Python :: load list from file python 
Python :: python dictionary print key value ascending order 
Python :: odoo model 
Python :: python permission denied on mac 
Python :: zip function python 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =