Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

select a range of rows in pandas dataframe

df.loc[np.r_[0:5, 10:15, 20:25], :]
Comment

python pandas how to select range of data

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.random((200,3)))
df['date'] = pd.date_range('2000-1-1', periods=200, freq='D')
mask = (df['date'] > '2000-6-1') & (df['date'] <= '2000-6-10')
print(df.loc[mask])
Comment

PREVIOUS NEXT
Code Example
Python :: numpy scale array 
Python :: How to Get the Union of Sets in Python 
Python :: create app in a django project 
Python :: python dict copy() 
Python :: python suppress warnings in function 
Python :: Modify a Python interpreter 
Python :: how to center a string python 
Python :: gradient descent python 
Python :: numpy put arrays in columns 
Python :: save image to file from URL 
Python :: add values to tuple python 
Python :: new column with addition of other columns 
Python :: how to print in double quotes in python 
Python :: generate random list and find max in list python 
Python :: uninstall a python package from virtualenv 
Python :: Reason: Worker failed to boot 
Python :: pandas filter on two columns 
Python :: scree plot sklearn 
Python :: TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use .set() instead 
Python :: import login required 
Python :: comment out multiple lines in python 
Python :: python bytes to string 
Python :: inverse mask python 
Python :: max between two numbers python 
Python :: Python program to find uncommon words from two Strings 
Python :: beautifulsoup getting data from a website 
Python :: python colored text into terminal 
Python :: django bulk update 
Python :: download pdf python 
Python :: pyspark average group by 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =