dgd-contributor opened a new pull request #33968:
URL: https://github.com/apache/spark/pull/33968


   ### What changes were proposed in this pull request?
   Fix update a series by another in same frame
   
   also add test for update series by one in diff frame
   
   ### Why are the changes needed?
   Fix update a series by another in same frame
   
   
   ### Does this PR introduce _any_ user-facing change?
   Before
   ```python
   >>> psdf = ps.DataFrame(
   ...     {"a": [None, 2, 3, 4, 5, 6, 7, 8, None], "b": [None, 5, None, 3, 2, 
1, None, 0, 0]},
   ... )
   >>> psdf
        a    b                                                                  
   
   0  NaN  NaN
   1  2.0  5.0
   2  3.0  NaN
   3  4.0  3.0
   4  5.0  2.0
   5  6.0  1.0
   6  7.0  NaN
   7  8.0  0.0
   8  NaN  0.0
   >>> psdf.a.update(psdf.b)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/Users/dgd/spark/python/pyspark/pandas/series.py", line 4551, in 
update
       combined = combine_frames(self._psdf, other._psdf, how="leftouter")
     File "/Users/dgd/spark/python/pyspark/pandas/utils.py", line 141, in 
combine_frames
       assert not same_anchor(
   AssertionError: We don't need to combine. `this` and `that` are same.
   >>> 
   ```
   
   After
   ```python
   >>> psdf = ps.DataFrame(
   ...     {"a": [None, 2, 3, 4, 5, 6, 7, 8, None], "b": [None, 5, None, 3, 2, 
1, None, 0, 0]},
   ... )
   >>> psdf
        a    b
   0  NaN  NaN
   1  2.0  5.0
   2  3.0  NaN
   3  4.0  3.0
   4  5.0  2.0
   5  6.0  1.0
   6  7.0  NaN
   7  8.0  0.0
   8  NaN  0.0
   >>> psdf.a.update(psdf.b)
   >>> psdf
        a    b
   0  NaN  NaN
   1  5.0  5.0
   2  3.0  NaN
   3  3.0  3.0
   4  2.0  2.0
   5  1.0  1.0
   6  7.0  NaN
   7  0.0  0.0
   8  0.0  0.0
   >>>
   ```
   
   ### How was this patch tested?
   unit tests
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to