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()