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

      list.pop 的 numpy 等效项?

      numpy-equivalent of list.pop?(list.pop 的 numpy 等效项?)

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

                <tbody id='GnfYQ'></tbody>

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

                本文介绍了list.pop 的 numpy 等效项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否有一个 numpy 方法等效于 python 列表的内置 pop 方法?

                Is there a numpy method which is equivalent to the builtin pop for python lists?

                Popping 显然不适用于 numpy 数组,我想避免列表转换.

                Popping obviously doesn't work on numpy arrays, and I want to avoid a list conversion.

                推荐答案

                NumPy 数组没有 pop 方法,但你可以只使用基本切片(这会很有效,因为它返回一个视图,而不是副本):

                There is no pop method for NumPy arrays, but you could just use basic slicing (which would be efficient since it returns a view, not a copy):

                In [104]: y = np.arange(5); y
                Out[105]: array([0, 1, 2, 3, 4])
                
                In [106]: last, y = y[-1], y[:-1]
                
                In [107]: last, y
                Out[107]: (4, array([0, 1, 2, 3]))
                

                如果有 pop 方法,它将返回 y 中的 last 值并修改 y.

                If there were a pop method it would return the last value in y and modify y.

                以上,

                last, y = y[-1], y[:-1]
                

                将最后一个值赋给变量last并修改y.

                assigns the last value to the variable last and modifies y.

                这篇关于list.pop 的 numpy 等效项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 数据框制作线图?)

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

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

                    <legend id='Zrh7b'><style id='Zrh7b'><dir id='Zrh7b'><q id='Zrh7b'></q></dir></style></legend>

                  1. <small id='Zrh7b'></small><noframes id='Zrh7b'>

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