在数据框中查找列的共现(Find co-occurrence of columns in dataframe)
我有一个包含数千列的数据框。 大多数列具有仅与其他列共存的值。 例如 :
A | B | C Null |"val" |"other" "random"|"rand"| Null
在这个例子中,我想要一个输出告诉我:
- 列与B共同出现
- B柱与A和C共同出现
- C柱与B共同出现
我可以编写某种循环并为每列做一些sql,但它会非常昂贵。
我使用python和任何可以帮助的库或代码是受欢迎的:)
对不起,如果使用错误的术语来描述问题...
谢谢
I have a dataframe of thousands of columns. Most of the columns have values that co-occur only with other columns. For example :
A | B | C Null |"val" |"other" "random"|"rand"| Null
In this exemple I would like an output that tells me :
- A column co-occur with B
- B column co-occur with A and C
- C column co-occur with B
I could write some kind of loop and do some sql for each column, but it will be really expensive.
I use python and any library or code that could help is welcome :)
Sorry if used the wrong terminology to describe the problem ...
Thanks
原文:https://stackoverflow.com/questions/41705406
最满意答案
是的,使用引导选择库很容易。 请参阅文档
您可以通过在您的网页中添加以下CSS和js CDN来使用它:
<!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css"> <!-- Latest compiled and minified JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script> <!-- (Optional) Latest compiled and minified JavaScript translation files --> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/i18n/defaults-*.min.js"></script>
一旦添加了CDN,您的HTML将如下所示:
<select class="selectpicker" data-size="5"> <option data-subtext="Heinz">Ketchup</option> </select>
在你的HTML下面,你必须定义
selectpicker
初始化JS函数,如:$('.selectpicker').selectpicker({ showSubtext:true });
Yes it is easily possible using bootstrap select library. See docs
You can use it by adding the below css and js CDNs in your webpage, :
<!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css"> <!-- Latest compiled and minified JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script> <!-- (Optional) Latest compiled and minified JavaScript translation files --> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/i18n/defaults-*.min.js"></script>
Once the CDN is added, your HTML will look like:
<select class="selectpicker" data-size="5"> <option data-subtext="Heinz">Ketchup</option> </select>
Beneath your HTML you have to have to define the
selectpicker
initialization JS function like:$('.selectpicker').selectpicker({ showSubtext:true });
相关问答
更多-
我相信clone()将是你的例子的最佳选择。 您也可以使用clone(true, true)按钮的行为(设置选项withDataAndEvents和deepWithDataAndEvents ) 。 运行以下代码检查: $(document).ready(function() { $(".add_button").click(function() { var currentRow = $(this).parents("tr"); var nr = currentRow.clone( ...
-
您可以使用.on()在选择上附加侦听器,以侦听更改事件。 使用change-event listener,只要有人更改了所选选项,您就可以执行操作。 然后,您可以使用.toggle()显示/隐藏输入,具体取决于用户在选择列表中选择的内容。 像这样的东西: $(function(){ $("select[name='menu-168']").on("change", function (){ $("input[name='text-708']").toggle( ...
-
是的,使用引导选择库很容易。 请参阅文档 您可以通过在您的网页中添加以下CSS和js CDN来使用它: