在多索引熊猫数据框中重置索引

时间:2020-06-02 10:40:46

标签: python pandas dataframe indexing pandas-groupby

我有一个DataFrame,看起来像这样

<ul class="dropdown-menu" aria-labelledby="topnavDocumentation" id="myDropdown">
           //Just removed <li></li> from here             
</ul>

<script>
    $(function () {

        $.getJSON('dashtrend.json', function (loadMainItem) {

            $.each(loadMainItem.data, function (i, f) {
                var makemenu = "<li class='dropright'><a href='#' class='dropdown-item dropdown-toggle'  id='" + f.id + "' role='button' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>" + f.text + "</a>";
                makemenu += "<div class='dropdown-menu' aria-labelledby='test'>";
                $.each(f.items, function (j) {
                        makemenu += "<a class='dropdown-item' href='" + f.items[j].navigationurl + "'>" + f.items[j].text + "</a>";

                })
                makemenu += "</div></li>";

                // <div class="dropdown-menu" aria-labelledby="ups4">
                //     <a class="dropdown-item" href="/Ups/UpsDashboard?upsid=1">Dashboard</a>
                //     <a class="dropdown-item" href="/Ups/Trends?id=1">Battery Trends</a>
                // </div>

                $(makemenu).appendTo("#myDropdown");
            });
        });

    });
</script>

Df I have

从长格式转换为宽格式的结果。 我想得到像这样的东西。

Df I want

0 个答案:

没有答案