Stream: helpdesk (published)

Topic: Remove Rows in DataFrame Based on Mismatch


view this post on Zulip Dale Black (Jul 21 2022 at 18:44):

Is there a way to filter different sized DataFrames and keep only the rows of both DataFrames where there are matching values in a specific column? E.g.

Given

df1_test = DataFrame(
    :col1 => ["low", "med", "high"],
    :col2 => ["a1", "b1", "c1"]
)
df2_test = DataFrame(
    :col1 => ["med"],
    :col2 => ["b2"]
)

I would like to return only the "med" row of each DataFrame since only "med" of :col1 are matching

df1_new = DataFrame(
    :col1 => ["med"],
    :col2 => ["b1"]
)
df2_new = DataFrame(
    :col1 => ["med"],
    :col2 => ["b2"]
)

Last updated: Oct 02 2023 at 04:34 UTC