Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get values using iloc

import pandas as pd
data = pd.DataFrame(listOfValues,columns=listWithColumnNames)

# Single selections using iloc and DataFrame
# Rows:
data.iloc[0] # first row of data frame (Aleshia Tomkiewicz) - Note a Series data type output.
data.iloc[1] # second row of data frame (Evan Zigomalas)
data.iloc[-1] # last row of data frame (Mi Richan)
# Columns:
data.iloc[:,0] # first column of data frame (first_name)
data.iloc[:,1] # second column of data frame (last_name)
data.iloc[:,-1] # last column of data frame (id)

# Multiple row and column selections using iloc and DataFrame
data.iloc[0:5] # first five rows of dataframe
data.iloc[:, 0:2] # first two columns of data frame with all rows
data.iloc[[0,3,6,24], [0,5,6]] # 1st, 4th, 7th, 25th row + 1st 6th 7th columns.
data.iloc[0:5, 5:8] # first 5 rows and 5th, 6th, 7th columns of data frame (county -> phone1).
Comment

PREVIOUS NEXT
Code Example
Python :: import a txt file into python 
Python :: how to add up everything in a list python 
Python :: ses mail name 
Python :: python merge csv files in same folder 
Python :: selenium python chrome path 
Python :: how to sort a column with mixed text number 
Python :: web server python 
Python :: python version check 
Python :: escape string for html python 
Python :: pyspark dataframe to single csv 
Python :: how to know where python is installed on windows 
Python :: convert torch to numpy 
Python :: change value to string pandas 
Python :: Update label text after pressing a button in Tkinter 
Python :: emoji in python 
Python :: get max value column pandas 
Python :: plt show 2 images 
Python :: how to find duplicate numbers in list in python 
Python :: __name__== __main__ in python 
Python :: matplotlib rc params 
Python :: default argument in flask route 
Python :: how to write to a file in python without deleting all content 
Python :: how to swap tuple 
Python :: how to import matplotlib.pyplo in python 
Python :: pygame escape key 
Python :: np load csv 
Python :: find python path cmd 
Python :: python run as service windows 
Python :: python tkinter set minimum window size 
Python :: python string cut substring 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =