title: how to calculate based on index?
body: <p>i have brunch of raw data in excel,
  column=company code,date(1year daily data),closing price,...
  will sort by company code and date
  it have around 900++ company in the list
  I import data to python and try to calculate brunch of calculation,
  for example I need first difference of closing price,
  data[&quot;first difference&quot;]=data[closing price]-data[closing price].shift()
  but the question is when change to next company, the difference will be calculated last day of first company data and the first day of company data, so I need a code to separate the company to calculate to data
  how to do it using python?
  i how you all can understand my description, thanks!</p>