select a range of column pandas code example
Example 1: 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])
Example 2: pandas from range of columns
df1.loc['d':, 'A':'C']