subsetting a Python DataFrame
I am transitioning from R to Python. I just began using Pandas. I have an R code that subsets nicely: k1 <- subset(data, Product = p.id & Month < mn & Year == yr, select = c(Time, Product)) Now, I want to do similar stuff in Python. this is what I have got so far: import pandas as pd data = pd.read_csv("../data/monthly_prod_sales.csv") #first, index the dataset by Product. And, get all that matches a given 'p.id' and time. data.set_index('Product') k = data.ix[[p.id, 'Time']] # then, index this subset with Time and do more subsetting.. I am beginning to feel that I am doing this the wrong way.