Skip to content

Instantly share code, notes, and snippets.

@DeastinY
Created May 20, 2019 10:19
Show Gist options
  • Save DeastinY/3291758adf1b402b46764d2dbd65b7d2 to your computer and use it in GitHub Desktop.
Save DeastinY/3291758adf1b402b46764d2dbd65b7d2 to your computer and use it in GitHub Desktop.
try:
df_a = pd.merge(x, y)
except pd.errors.MergeError: # occurs if only interventionids are used
df_a = None
try:
df_b = pd.merge(x, y)
except pd.errors.MergeError: # occurs if only attributeids are used
df_b = None
if df_a is None and df_b is None:
logging.error("Problems with merging!")
elif df_a is None:
df = df_b
elif df_b is None:
df = df_a
else:
df = pd.concat([df_a, df_b])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment