cow.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. _chained_assignment_msg = (
  2. "A value is being set on a copy of a DataFrame or Series "
  3. "through chained assignment.\n"
  4. "Such chained assignment never works to update the original DataFrame or "
  5. "Series, because the intermediate object on which we are setting values "
  6. "always behaves as a copy (due to Copy-on-Write).\n\n"
  7. "Try using '.loc[row_indexer, col_indexer] = value' instead, to perform "
  8. "the assignment in a single step.\n\n"
  9. "See the documentation for a more detailed explanation: "
  10. "https://pandas.pydata.org/pandas-docs/stable/user_guide/"
  11. "copy_on_write.html#chained-assignment"
  12. )
  13. _chained_assignment_method_msg = (
  14. "A value is being set on a copy of a DataFrame or Series "
  15. "through chained assignment using an inplace method.\n"
  16. "Such inplace method never works to update the original DataFrame or Series, "
  17. "because the intermediate object on which we are setting values always "
  18. "behaves as a copy (due to Copy-on-Write).\n\n"
  19. "For example, when doing 'df[col].method(value, inplace=True)', try "
  20. "using 'df.method({col: value}, inplace=True)' instead, to perform "
  21. "the operation inplace on the original object, or try to avoid an inplace "
  22. "operation using 'df[col] = df[col].method(value)'.\n\n"
  23. "See the documentation for a more detailed explanation: "
  24. "https://pandas.pydata.org/pandas-docs/stable/user_guide/"
  25. "copy_on_write.html"
  26. )
  27. _chained_assignment_method_update_msg = (
  28. "A value is being set on a copy of a DataFrame or Series "
  29. "through chained assignment using an inplace method.\n"
  30. "Such inplace method never works to update the original DataFrame or Series, "
  31. "because the intermediate object on which we are setting values always "
  32. "behaves as a copy (due to Copy-on-Write).\n\n"
  33. "For example, when doing 'df[col].update(other)', try "
  34. "using 'df.update({col: other})' instead, to perform "
  35. "the operation inplace on the original object.\n\n"
  36. "See the documentation for a more detailed explanation: "
  37. "https://pandas.pydata.org/pandas-docs/stable/user_guide/"
  38. "copy_on_write.html"
  39. )