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 :: valor absoluto en python 
Python :: calculate the distance between two points 
Python :: python drop all variable that start with the same name 
Python :: python convert string to bytes 
Python :: python set timezone of datetime.now 
Python :: flask quickstart 
Python :: play sound on python 
Python :: lambda condition python 
Python :: select rows from a list of indices pandas 
Python :: pandas bin columns 
Python :: 2d dictionary in python 
Python :: secondary y axis matplotlib 
Python :: multiclass ROC AUC curve 
Python :: python currency format locale 
Python :: split data train, test by id python 
Python :: # How to Prints the current working directory in python 
Python :: How to print a groupby object 
Python :: flask port 
Python :: add one day to datetime 
Python :: create dataframe from two variables 
Python :: how to count the occurrence of a word in string python 
Python :: how to play mp3 files using vlc python library 
Python :: drawing arrows in tkinter 
Python :: django login view 
Python :: python find directory of file 
Python :: slice dataframe pandas based on condition 
Python :: root mean square python 
Python :: import get object 
Python :: python xml to csv 
Python :: pick a random number from a list in python 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =