如何在Jupy中插入javascript代码

2024-10-03 09:09:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试着在自定义.js. 我把所有的负货币都换成红色。在

我希望它适用于所有打印在Jupyter上的pandas数据帧。添加到所有自定义.js在jupyter/anaconda文件夹中可用,它仍然没有改变任何东西。有人能帮我吗?在

var allTableCells = document.getElementsByTagName("td");
for(var i = 0, max = allTableCells.length; i < max; i++) {
    var node = allTableCells[i];

    //get the text from the first child node - which should be a text node
    var currentText = node.childNodes[0].nodeValue; 

    //check for 'one' and assign this table cell's background color accordingly 
    if (currentText.includes("$ -"))
        node.style.color = "red";
}

Tags: the数据textnodepandasforvarjs
1条回答
网友
1楼 · 发布于 2024-10-03 09:09:28

use the jupyter javascript magic

%%javascript
var allTableCells = document.getElementsByTagName("td");
for(var i = 0, max = allTableCells.length; i < max; i++) {
    var node = allTableCells[i];

    //get the text from the first child node - which should be a text node
    var currentText = node.childNodes[0].nodeValue; 

    //check for 'one' and assign this table cell's background color accordingly 
    if (currentText.includes("$ -"))
        node.style.color = "red";
}

相关问题 更多 >