I have this:
oTable = $("#bla").dataTable({
"iDisplayLength": 50,
"aLengthMenu": [[5, 25, 50, 100, 250, -1], [5, 25, 50, 100, 250, "All"]],
"sDom": "<'call-header'<'dthead'><'ttools'T><'filterinput'f>r><'dttoolbar'><'dataTables_scroll'<'dataTables_scrollBody't>><'call-footer'<'row-fluid'<'span6'i><'span6'p>>>",
.... });
If I comment out the sDom part, I get my length menu and I am able to select the number of items to show on the page. But with the SDOM variable, this just disappears.
I've tried combinations of adding:
<'dataTables_length'>
But I think I am misunderstanding how it works. Can anyone clarify how this must be done?
See the documentation for sDom - the sDom code for Length changing is l.
Here the length menu is being inserted as the very first control :
sDom: "<'call-header'<'dthead'>l<'ttools'T><'filterinput'f>r><'dttoolbar'><'dataTables_scroll'<'dataTables_scrollBody't>><'call-footer'<'row-fluid'<'span6'i><'span6'p>>>"
---^---
fiddle -> http://jsfiddle.net/eCrhb/
Related
Below is example data which are probabilities from predict_proba. I want to split this data frame into deciles but with equal number of rows in each decile. I used pd.qcut but with that because of the repeating values at the boundary the rows in each decile become unequal.
I used below method to get equal splits which worked but problem is with this approach I can't get bins(range).
test_df["TOP_DECILE"] = pd.qcut(test_df["VALIDATION_PROB_1"].rank(method='first'), 10, retbins = False, labels = [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
For each decile we need to see the probability range as well. This is how we need final output:
Is there a clean implementation we can do achieve this?
This is how I implemented finally:
test_df["TOP_DECILE"] = pd.qcut(test_df["VALIDATION_PROB_1"].rank(method='first'), 10, retbins = False, labels = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10])
test_df = test_df.merge(test_df.groupby('TOP_DECILE')["VALIDATION_PROB_1"].agg(['min', 'max']), right_index=True, left_on='TOP_DECILE')
test_df["PROBILITY_RANGE"] = "[" + (test_df["min"]).astype(str) + " - " + test_df["max"].astype(str) + "]"
But there should be a cleaner approach.
I need to multiply an array (NIR) with a scalar (f) but leaving some values that meet a certain condition intact.
I tried the following:
NIR_f = np.multiply(NIR,f,where=NIR!=-28672.0)
To check I made:
i,j=1119,753
NIR[i][j],NIR_f[i][j]
and I got this:
(-28672.0, 10058.0)
It is assumed that both results should be the same! In that position the condition is not met, therefore the value should remain intact.
Am I using the "where" option wrongly?
Without your array, or a smaller substitute, I can't exactly replicate your problem. But there are potentially 2 issues
float testing is not exact, so it might be matching one -28672.0, and not another.
the remain intact assumption is tricky. leave the value in the output alone, but what was it originally, 0's or NIR values.
Using an integer array to avoid the float issue:
In [20]: arr = np.arange(12).reshape(3,4)
In [21]: arr
Out[21]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
In [22]: np.multiply(arr, 10, where=arr!=10)
Out[22]:
array([[ 0, 10, 20, 30],
[ 40, 50, 60, 70],
[ 80, 90, 481036337249, 110]])
In [24]: np.multiply(arr, 10, where=arr!=10)
Out[24]:
array([[ 0, 10, 20, 30],
[ 40, 50, 60, 70],
[ 80, 90, 0, 110]])
arr[2,2] is random. In effect it started with a np.empty array of the right shape and dtype, and filled all values but that one with the multiplication. To use where correctly we need to specify an out parameter as well.
In [25]: out = np.full(arr.shape,-1)
In [26]: out
Out[26]:
array([[-1, -1, -1, -1],
[-1, -1, -1, -1],
[-1, -1, -1, -1]])
In [27]: np.multiply(arr, 10, where=arr!=10, out=out)
Out[27]:
array([[ 0, 10, 20, 30],
[ 40, 50, 60, 70],
[ 80, 90, -1, 110]])
The issue of inexact floats comes up often enough that I won't try to illustrate that.
I am facing a problem when printing pos invoice by MPDF. I don't want to set a fixed height of pdf page. Page height will be adjusted by its content. Here the line of my controller's function from where I am calling MPDF.
$mPDF1 = Yii::app()->ePdf->mpdf('',array('80','130'), 8, '', 5, 5, 5, 5, 0, 0, 'P');
Please give me some idea how to get expected page size.
pls try this
$mpdf=new mPDF('c', 'A4', 0, 'Arial', 10, 10, 10, 10, 10, 10);
OR
$mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
I've been using the datatable jquery (http://datatables.net/ ) plugin.
Everything is working fine, but now I want to be able to select more than the default options of records per page, by default I can choose 10 , 25 , 50 , 100. I want to add 15 and 30 to this list.
How can I do that, I searched on internet but could't find any answer.
Thanks
Use pageLength and lengthMenu for setting the default view, like this:
$('#example').DataTable({
"pageLength": 15,
"lengthMenu": [[10, 15, 25, 35, 50, 100, -1], [10, 15, 25, 35, 50, 100, "All"]]
});
old api
$('#example').dataTable({
"iDisplayLength": 15,
"aLengthMenu": [[10, 15, 25, 35, 50, 100, -1], [10, 15, 25, 35, 50, 100, "All"]]
});
Second array will hold the values for that will be displayed in the drop down menu
Read more: DataTables example - Page length options
what are the interpretation values in the"" points assignment. all I want is a "plane jane" line where I can manipulate the length and width. Any help will greatly appreciated.
var line = new Kinetic.Line({
x: 100,
y: 50,
points: [73, 70, 340, 23, 450, 60, 500, 20],
stroke: 'red',
tension: 1
});
The points array is a series of x,y coordinates:
// [73, 70, 340, 23, 450, 60, 500, 20],
{x:73,y:70},
{x:340,y:23},
{x:450,y:60},
{x:500,y:20}
This is your "plain jane" line:
// draw a black line from 25,25 to 100,50 and width of 5
var line = new Kinetic.Line({
points:[25,25, 100,50],
y:100,
stroke: 'black',
strokeWidth: 5
});