0

I have two dataframes that I am joining based on client name. The issue is that for my dataframe called screening the name is formatted as Lastname, Firstname, and my other dataframe uses Firstname Lastname. I use the following code to split the Screening["Client"] column into separate first name and last name columns, however, when concatenating the new string into the column full_name I am given a SettingWithCopyWarning.

#
names = screening["Client"].str.split(", ", n = 1, expand = True)
screening["full_name"] = names[1].copy().str.title() + " " + names[0].copy().str.title()

This is the error I am getting

SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  screening["full_name"] = names[1].copy().str.title() + " " + names[0].copy().str.title()
Jordin M
  • 31
  • 4
  • 1
    Does this answer your question? [How to deal with SettingWithCopyWarning in Pandas](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – wavingtide Oct 26 '22 at 17:30

0 Answers0