I may be overcomplicating this problem, however I can't seem to find a simple solution.
I have two DataFrame's. Let's call them df1 and df2. To keep things simple. Let's say df1 has one column called "Some Data" and df2 has two columns called "some data" and "other data".
Example:
df1
Some Data
"Lebron James 123"
"Lebron James 234"
df2
some data other data
"Lebron James 123 + other text" "I want this in df1["New?"]"
"Michael Jordan" "Doesn't Matter"
So basically I want to create a new column in df1 called "New?". This new column (in df1) will say "New" if df1["Some data"] is in df2["Some other data"]. However, if there is no instance in df2["some data"], then I set the df1["New?"] to that specific row's value in df2["other data"].
Desired result after running:
df1
Some Data New?
"Lebron James 123" "I want this in df1["New?"]"
"Lebron James 234" "New"
So as you can see The New? column would include that specific row's value from the other data column. Lebron James 234 isn't anywhere in some data in df2 so it says new.
I am able to get it to say True or False using the .isin() method, however don't know how to grab the index of the other df and get the value from the other data column.
Thank you
EDIT:
From what I know will work
df["New?"] = df1["Some Data"].isin(df2["some data"])
Would render
df1["New?"]
True
False
So I want True to be the "I want this in df1["New?"]" and False to be New
df1appears in more than one row in df2? - rafaelcdf1? Seems like you should have+ other textin first row, otherwise it wouldn't yieldTruein your output - rafaelc