Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get a row from a dataframe in python

df.iloc[[index]]
Comment

pandas select a row

#select the first row 
df.iloc[1]
#select the first row and return the value in column ['Biologie']
candidate_df.iloc[1]['Biologie']
Comment

pandas return specific row

df.iloc[1] # replace index integer with specific row number
Comment

pandas return row

1. 	Selecting data by row numbers (.iloc)
	# myrow = data.iloc[<row selection>]
 	myrow = data.iloc[7]
    myrow = data.iloc[0:9]
    
2. 	Selecting data by label or by a conditional statement (.loc)
	# myrow = data.loc[<row selection.]
  	myrow = data.loc['University ABC']
    
3. 	Selecting in a hybrid approach (.ix) (now Deprecated in Pandas 0.20.1)
	# Works like a .loc but also accepts integers - may lead to unexpected results
Comment

PREVIOUS NEXT
Code Example
Python :: python trim whitespace from end of string 
Python :: pandas apply lambda function with assign 
Python :: python read values from file 
Python :: cardano 
Python :: python use functions from another file 
Python :: create pyspark dataframe from list 
Python :: Exception Value: Object of type User is not JSON serializable 
Python :: list comprehension if elseif 
Python :: if else in list comprehension 
Python :: np.select with multiple conditions 
Python :: variable string in string python 
Python :: python 1 line for loop with else 
Python :: django password field 
Python :: python merge list of lists 
Python :: find max in a dataframe 
Python :: python timer 
Python :: get function in dictionary 
Python :: python array 
Python :: planet 
Python :: Returns a new DataFrame omitting rows with null values 
Python :: python numpy array 
Python :: how to set and run flask app on terminal 
Python :: python window icon on task bar 
Python :: python check if list contains value 
Python :: pi in python 
Python :: dict get list of values 
Python :: nice python turtle code 
Python :: python - regexp to find part of an email address 
Python :: how to add csrf token in python requests 
Python :: conda install pypy 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =