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

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

<legend id='N28DW'><style id='N28DW'><dir id='N28DW'><q id='N28DW'></q></dir></style></legend>
  • <tfoot id='N28DW'></tfoot>
      <bdo id='N28DW'></bdo><ul id='N28DW'></ul>

      1. 试图在来自 DF 的切片副本上设置值

        Value is tryin to be set on a copy of a slice from DF(试图在来自 DF 的切片副本上设置值)

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

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

                  <tbody id='bbnOR'></tbody>

                  <i id='bbnOR'><tr id='bbnOR'><dt id='bbnOR'><q id='bbnOR'><span id='bbnOR'><b id='bbnOR'><form id='bbnOR'><ins id='bbnOR'></ins><ul id='bbnOR'></ul><sub id='bbnOR'></sub></form><legend id='bbnOR'></legend><bdo id='bbnOR'><pre id='bbnOR'><center id='bbnOR'></center></pre></bdo></b><th id='bbnOR'></th></span></q></dt></tr></i><div id='bbnOR'><tfoot id='bbnOR'></tfoot><dl id='bbnOR'><fieldset id='bbnOR'></fieldset></dl></div>
                  本文介绍了试图在来自 DF 的切片副本上设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在用 pandas 和 python 做一些事情.我有下一个代码

                  Im doing some stuff with pandas and python. I have the next code

                  df = pd.read_csv("Request.csv", keep_default_na=False)
                  df1 = df.loc[(df["Request Status"] == "Closed")]
                  df1["Request Close-Down Actual"] = pd.to_datetime(df1["Request Close-Down Actual"], errors = 'coerce' )
                  df3 = df1.loc[(df1["Request Close-Down Actual"] < '2016-11-01') | (df1["Request Close-Down Actual"].isnull())]        
                  df3.set_index("Request ID", inplace = True)
                  df3.to_csv("Request1.csv")
                  

                  问题是当我运行代码时,我会收到下一个问题

                  The issue is when i run the code i receive the next issue

                  试图在数据帧的切片副本上设置值

                  A value is trying to be set on a copy of a slice from a DataFrame

                  df1.loc[请求关闭实际"] = pd.to_datetime(df1[请求Close-Down Actual"], errors = 'coerce')

                  df1.loc["Request Close-Down Actual"] = pd.to_datetime(df1["Request Close-Down Actual"], errors = 'coerce' )

                  请有人帮我解决这个问题.谢谢

                  Can someone give me a hand with this please. Thanks

                  推荐答案

                  我测试了它,对我来说效果很好.

                  I test it and for me it works nice.

                  问题应该在上面一行:

                  df1 = df.loc[(df["Request Status"] == "Closed")]
                  

                  解决方案是 copy:

                  And solution is copy:

                  #loc is not necessary
                  df1 = df[df["Request Status"] == "Closed"].copy()
                  

                  <小时>

                  错误显示 loc - 如果需要选择列,请尝试删除它:


                  Error show loc - try remove it if need select column:

                  df1.loc["Request Close-Down Actual"] = pd.to_datetime(df1["Request Close-Down Actual"], errors = 'coerce' )
                  

                  到:

                  df1["Request Close-Down Actual"] = pd.to_datetime(df1["Request Close-Down Actual"], errors = 'coerce' )
                  

                  这篇关于试图在来自 DF 的切片副本上设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                  <tfoot id='OHBYc'></tfoot>

                    <tbody id='OHBYc'></tbody>

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

                      <bdo id='OHBYc'></bdo><ul id='OHBYc'></ul>

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