daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. import numpy as np
  3.  
  4. prueba = pd.DataFrame({'index':['1','2','3'],
  5.                        'col_1': [0,2,3],
  6.                        'col_2':[1,4,5]})
  7. def data_cleaner(row):
  8.     valores_col_1 = [0]
  9.     valores_col_2 = [5]
  10.     for a in valores_col_1:
  11.         if row['col_1'] == a:
  12.             return 777
  13.         else:
  14.             return row['col_1']
  15.     for b in valores_col_2:
  16.         if row['col_2'] == b:
  17.             return 999
  18.         else:
  19.             return row['col_1']
  20.  
  21. prueba["col_1"] = prueba.apply(data_cleaner,axis = 1)
  22. prueba["col_2"] = prueba.apply(data_cleaner,axis = 1)
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