Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python - row slice dataframe by number of rows

df.iloc[[1, 5]]                                               # Get rows 1 and 5
df.iloc[1:6]                                                  # Get rows 1 to 5 inclusive
df.iloc[[1, 5], df.columns.get_loc('Shop')]                   # Get only specific column
df.iloc[[1, 5], df.columns.get_indexer(['Shop', 'Category'])] # Get multiple columns
Comment

PREVIOUS NEXT
Code Example
Python :: python read from stdin 
Python :: python get position of character in string 
Python :: OneHotEncoder(categorical_features= 
Python :: split list in half python 
Python :: IntegrityError import in django 
Python :: python find closest lower value in list 
Python :: binary to decimal in python 
Python :: datetime to unix timestamp milliseconds python 
Python :: 3d array in numpy 
Python :: python undefine variable 
Python :: 2 for loops at the same time in Python 
Python :: how to underline text in tkinter 
Python :: difference between compiler and interpreter 
Python :: find closest color python 
Python :: python sqlite insert 
Python :: python [remote rejected] master - master (pre-receive hook declined) 
Python :: pytorch view -1 meaning 
Python :: python - remove duplicate items from the list 
Python :: df index start from 1 
Python :: UTC to ISO 8601: 
Python :: python program to count even and odd numbers in a list 
Python :: run python file using python code 
Python :: measure execution time in jupyter notebook 
Python :: current date to epoch python 
Python :: print column in 2d numpy array 
Python :: python string to list with separator 
Python :: python divisors 
Python :: how to use xpath with beautifulsoup 
Python :: python Non-UTF-8 code starting with 
Python :: python send get request with headers 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =