0

I have two dataframes certdf and df that I have compared using:

certdf['SampNum'].isin(df['SampNum']).value_counts()

resulting in:

True     730
False    170
Name: SampNum, dtype: int64

I want to export the 170 rows from certdf that are not present in df into their own dataframe. Eventually I will simply add these values to df, but I also need to export them as an independant xlsx file. My thought was that if I can get the values as an independant dataframe, I can use ExcelWriter to spit out my file. I'm new to python, but not to scripting, so I know this is probably really simple, but I can't figure it out. Thanks.

  • `two_dataframe_dict = {k: d for k, d in certdf.groupby(certdf.SampNum.isin(df.SampNum))}` – piRSquared Mar 24 '21 at 01:30
  • https://stackoverflow.com/questions/33036804/compare-two-dataframes-and-filter-items-only-listed-in-the-second – aj7amigo Mar 24 '21 at 01:32
  • Merge left excluding join in [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – DarrylG Mar 24 '21 at 01:34
  • thanks everyone. i feel a little silly, actually. this worked perfectly: `diffdf = certdf[~certdf['SampNum'].isin(df['SampNum'])]` – Chloe Peterson Mar 24 '21 at 01:55

0 Answers0