daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd, numpy as np
  2.  
  3. columns = ['Location','Hourly','Annually','Monthly','Daily','Average','Hourly_Rate','Annual_Rate']
  4. df = pd.DataFrame(columns=columns)
  5. df.loc[1] = ['A',True,False,False,False,10.10,np.nan,np.nan]
  6. df.loc[2] = ['A',False,True,False,False,50000,np.nan,np.nan]
  7.  
  8. df['Annual_Rate'] = (df['Average'] * 2080).where(df['Hourly'] == True) #need this line to run and not get overwritten
  9. df['Annual_Rate'] = df['Average'].where(df['Annually'] == True ) #overwrites prior line
  10. df['Annual_Rate'] = df['Average'].where(df['Annually'] == True & pd.isna(df['Annual_Rate'])) #overwrites prior line and is incorrect
  11.  
  12. df['Hourly_Rate'] = (df['Average'] / 2080).where([(df['Annually'] == True) & (pd.isnull(df['Hourly_Rate']))])
  13. df['Hourly_Rate'] = df['Average'].where(df['Hourly'] == True & (pd.isna(df['Hourly_Rate'])))
  14. df['Hourly_Rate'] = df['Average'].where(df['Hourly'] == True)
  15. df.head(10)
  16.    
  17. df['Hourly_Rate'] = (df['Average'] / 2080).where([(df['Annually'] == True) & (pd.isnull(df['Hourly_Rate']))])
  18. df['Annual_Rate'] = (df['Average'] * 2080).where(df['Hourly'] == True)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top