Skip to content

Instantly share code, notes, and snippets.

@BBischof
Created February 22, 2017 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBischof/002776f5e56733644e48e913fe96c157 to your computer and use it in GitHub Desktop.
Save BBischof/002776f5e56733644e48e913fe96c157 to your computer and use it in GitHub Desktop.
ternary applied to fix a np.column with some nulls based on index
'''does something to an i'''
def f:
return i
s = pd.Series([f(i) for i in df.index])
df['A'] = np.where(df['A'].notnull(), df['A'],s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment