Skip to content

Instantly share code, notes, and snippets.

@ashtom84
Created March 24, 2016 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashtom84/af2f0598b7d9c42a9a4d to your computer and use it in GitHub Desktop.
Save ashtom84/af2f0598b7d9c42a9a4d to your computer and use it in GitHub Desktop.
%select only brands with 101 models listed at least
bkmake = bkmake[bkmake['makesize'] > 100]
bkmake['ydist'] = bkmake.km/(2017 - bkmake.year)
bkmake = bkmake.loc[np.logical_not(np.isnan(bkmake.ydist))]
# selecting only the 95% percentile
nM = 95
nR = 100
ydistmax = np.nanpercentile(bkmake.ydist, nM)
ydistr = np.arange(0, ydistmax + nR, nR)
# adapting the variable to the new resolution
ydistg = []
for dist in bkmake.ydist:
if dist < ydistmax:
ydistg.append(ydistr[(ydistr >= dist) & (ydistr < dist + nR)][0])
else:
ydistg.append(ydistmax)
bkmake['ydist'] = ydistg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment