Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. def replace_expiration(df):
  2.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de enero', '-01')
  3.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de febrero', '-02')
  4.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de marzo', '-03')
  5.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de abril', '-04')
  6.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de mayo', '-05')
  7.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de junio', '-06')
  8.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de julio', '-07')
  9.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de agosto', '-08')
  10.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de septiembre', '-09')
  11.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de octubre', '-10')
  12.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de noviembre', '-11')
  13.     df['fecha_vencimiento'] = df['fecha_vencimiento'].str.replace(' de diciembre', '-12')
  14.    
  15.     return df
  16.  
  17. data_c1_comp = replace_expiration(data_c1_comp) #This can be done by reference, but it prints the return and its slow
  18.  
  19. data_c1_comp['fecha_compromiso'] = pd.to_datetime(data_c1_comp['fecha_compromiso'], format='%Y-%m-%d')
  20. data_c1_comp['fecha_llamada'] = pd.to_datetime(data_c1_comp['DATE'], format='%Y-%m-%d')
  21. data_c1_comp['fecha_vencimiento'] = pd.to_datetime(data_c1_comp['fecha_vencimiento'], format='%d-%m')
  22.  
  23. data_c1_comp.head()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement