I've working on python for my current project and constantly longing for R's syntax specifically for cleaning data. It's so much better.
Just last night, I wanted to perform an anti-join to find discrepancies between two data sets for debugging
One line in R:
anti_join(a_tibble, another_tibble, by = c("id_col1", "id_col2"))
Witchcraft in Pandas: (from stack overflow): Method 1
# Identify what values are in TableB and not in TableA
key_diff = set(TableB.Key).difference(TableA.Key)
where_diff = TableB.Key.isin(key_diff)
# Slice TableB accordingly and append to TableA
TableA.append(TableB[where_diff], ignore_index=True)
Method 2:
rows = []
for i, row in TableB.iterrows():
if row.Key not in TableA.Key.values:
rows.append(row)
pd.concat([TableA.T] + rows, axis=1).T
I actually fired up R and re-imported the .csv data just for this. Took 15 secs while my colleague was still stuck debugging his own weird for loops.