Created
March 24, 2016 13:22
-
-
Save ashtom84/af2f0598b7d9c42a9a4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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