import pandas as pd import numpy as np df = pd.read_excel("../in/sample-salesv3.xlsx") df.dtypes df['date'] = pd.to_datetime(df['date']) df.head() df.dtypes df[df["account number"]==307599].head() df[df["quantity"] > 22].head() df[df["sku"].map(lambda x: x.startswith('B1'))].head() df[df["sku"].map(lambda x: x.startswith('B1')) & (df["quantity"] > 22)].head() df[df["account number"].isin([714466,218895])].head() df.query('name == ["Kulas Inc","Barton LLC"]').head() df = df.sort('date') df.head() df[df['date'] >='20140905'].head() df[df['date'] >='2014-03'].head() df[(df['date'] >='20140701') & (df['date'] <= '20140715')].head() df[df['date'] >= 'Oct-2014'].head() df[df['date'] >= '10-10-2014'].head() df2 = df.set_index(['date']) df2.head() df2["20140101":"20140201"].head() df2["2014-Jan-1":"2014-Feb-1"].head() df2["2014-Jan-1":"2014-Feb-1"].tail() df2["2014"].head() df2["2014-Dec"].head() df[df['sku'].str.contains('B1')].head() df[(df['sku'].str.contains('B1-531')) & (df['quantity']>40)].sort(columns=['quantity','name'],ascending=[0,1]) df["name"].unique() df.drop_duplicates(subset=["account number","name"]).head() df.drop_duplicates(subset=["account number","name"]).ix[:,[0,1]]