1. <tfoot id='H6Tvv'></tfoot>

    <legend id='H6Tvv'><style id='H6Tvv'><dir id='H6Tvv'><q id='H6Tvv'></q></dir></style></legend>
        <bdo id='H6Tvv'></bdo><ul id='H6Tvv'></ul>

      <i id='H6Tvv'><tr id='H6Tvv'><dt id='H6Tvv'><q id='H6Tvv'><span id='H6Tvv'><b id='H6Tvv'><form id='H6Tvv'><ins id='H6Tvv'></ins><ul id='H6Tvv'></ul><sub id='H6Tvv'></sub></form><legend id='H6Tvv'></legend><bdo id='H6Tvv'><pre id='H6Tvv'><center id='H6Tvv'></center></pre></bdo></b><th id='H6Tvv'></th></span></q></dt></tr></i><div id='H6Tvv'><tfoot id='H6Tvv'></tfoot><dl id='H6Tvv'><fieldset id='H6Tvv'></fieldset></dl></div>

      <small id='H6Tvv'></small><noframes id='H6Tvv'>

      列中具有多个标签的一种热编码

      One Hot Encoding with multiple tags in the column(列中具有多个标签的一种热编码)
        <bdo id='GVw5v'></bdo><ul id='GVw5v'></ul>
          <tbody id='GVw5v'></tbody>

        <small id='GVw5v'></small><noframes id='GVw5v'>

            <i id='GVw5v'><tr id='GVw5v'><dt id='GVw5v'><q id='GVw5v'><span id='GVw5v'><b id='GVw5v'><form id='GVw5v'><ins id='GVw5v'></ins><ul id='GVw5v'></ul><sub id='GVw5v'></sub></form><legend id='GVw5v'></legend><bdo id='GVw5v'><pre id='GVw5v'><center id='GVw5v'></center></pre></bdo></b><th id='GVw5v'></th></span></q></dt></tr></i><div id='GVw5v'><tfoot id='GVw5v'></tfoot><dl id='GVw5v'><fieldset id='GVw5v'></fieldset></dl></div>
              <legend id='GVw5v'><style id='GVw5v'><dir id='GVw5v'><q id='GVw5v'></q></dir></style></legend>
              <tfoot id='GVw5v'></tfoot>

                本文介绍了列中具有多个标签的一种热编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个简单的数据集.

                I have a simple dataset.

                id,question,category,tags,day,quarter,group_id
                
                1,What is your name,Introduction,Introduction,1,3,0
                
                2,What is your name,Introduction,"Introduction, work",1,3,1
                

                现在,如果您看到,在 tags 列中有多个用逗号分隔的输入.如果我尝试使用 pandas get_dummies 函数进行一次热编码,我会将其作为单列获取.但我想为每个标签创建列.我怎么可能做到这一点?

                Now if you see, in the tags column there are multiple inputs seperated by commas. If I try to one-hot-encode using pandas get_dummies function I will get that as a single column. But I wanted to create columns for each tags. How can I do that possibly?

                推荐答案

                相信需要str.get_dummies:

                df1 = df['tags'].str.get_dummies(', ')
                print (df1)
                
                   Introduction  work
                0             1     0
                1             1     1
                

                这篇关于列中具有多个标签的一种热编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                <small id='umMxr'></small><noframes id='umMxr'>

                • <bdo id='umMxr'></bdo><ul id='umMxr'></ul>

                  <tfoot id='umMxr'></tfoot>
                    <tbody id='umMxr'></tbody>

                  1. <legend id='umMxr'><style id='umMxr'><dir id='umMxr'><q id='umMxr'></q></dir></style></legend>
                      <i id='umMxr'><tr id='umMxr'><dt id='umMxr'><q id='umMxr'><span id='umMxr'><b id='umMxr'><form id='umMxr'><ins id='umMxr'></ins><ul id='umMxr'></ul><sub id='umMxr'></sub></form><legend id='umMxr'></legend><bdo id='umMxr'><pre id='umMxr'><center id='umMxr'></center></pre></bdo></b><th id='umMxr'></th></span></q></dt></tr></i><div id='umMxr'><tfoot id='umMxr'></tfoot><dl id='umMxr'><fieldset id='umMxr'></fieldset></dl></div>