Skip to content

Instantly share code, notes, and snippets.

@cigrainger
Created August 14, 2014 15:28
Show Gist options
  • Save cigrainger/b04cac5fea921267ddc2 to your computer and use it in GitHub Desktop.
Save cigrainger/b04cac5fea921267ddc2 to your computer and use it in GitHub Desktop.
for firm in pd.unique(firms.bvdid):
firms.ix[((firms.bvdid==firm)&(firms.year==2004)),'stock'] = firms.stock[(firms.bvdid==firm)&(firms.year==2004)] + firms.patents[(firms.bvdid==firm)&(firms.year==2004)]
for i in range(2005,2014):
firms.ix[((firms.bvdid==firm)&(firms.year==i)),'stock'] = firms.stock[(firms.bvdid==firm)&(firms.year==i-1)] + firms.patents[(firms.bvdid==firm)&(firms.year==i)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment