我的数据集是2个浮点数类型的比率。对于无穷大(除以零)情况,某些值具有inf
。如何使用pd.qcut/pd.cut
inf
值处理q = pd.qcut(df['ratio'], 10)
ValueError: Bin edges must be unique: array([ 1.20089207e+03, 6.02984295e+04, 1.26445577e+05,
2.29982770e+05, 5.13176079e+05, 1.28794976e+06,
4.96001538e+06, nan, nan,
nan, inf])
?
我的数据可以访问here。
var locations = [
{name: 'point 0', location: [50.8674162,4.3772933]},
{name: 'point 1', location: [50.8135113,4.3247394]},
{name: 'point 2', location: [50.8771732,4.3544551]},
{name: 'point 3', location: [50.8460485,4.3664706]}
];
function generateUl() {
for(var i in locations) {
li = $('<li>'+ locations[i].name +' ('+ locations[i].location.toString() +')</li>');
li.data('d', locations[i])
$('#points').append(li);
}
}
$(document).ready(function() {
generateUl();
$('#points').sortable({
update: function(event, ui) {
new_locations = $(this).find('li').map(function(i, el) {
return $(el).data('d')
}).get()
$('#display').html(JSON.stringify(new_locations));
}
});
});
答案 0 :(得分:1)
您可以replace
np.inf
与np.nan
然后dropna
q = pd.qcut(df.ratio.replace(np.inf, np.nan).dropna(), 10)