Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Source Month Sessions Bounce Rate Avg. Session Duration
  2. ABC.com 201501 408 26.47% 0:03:26
  3.  
  4. def time_convert(x):
  5. times = x.split(':')
  6. return (60*int(times[0])+60*int(times[1]))+int(times[2])
  7.  
  8. df['Avg. Session Duration'] = df['Avg. Session Duration'].apply(time_convert)
  9.  
  10. > --------------------------------------------------------------------------- AttributeError Traceback (most recent call
  11. > last) <ipython-input-53-01e79de1cb39> in <module>()
  12. > ----> 1 df['Avg. Session Duration'] = df['Avg. Session Duration'].apply(lambda x: x.split(':'))
  13. >
  14. > /Users/yumiyang/anaconda/lib/python2.7/site-packages/pandas/core/series.pyc
  15. > in apply(self, func, convert_dtype, args, **kwds) 1991
  16. > values = lib.map_infer(values, lib.Timestamp) 1992
  17. > -> 1993 mapped = lib.map_infer(values, f, convert=convert_dtype) 1994 if len(mapped) and
  18. > isinstance(mapped[0], Series): 1995 from
  19. > pandas.core.frame import DataFrame
  20. >
  21. > /Users/yumiyang/anaconda/lib/python2.7/site-packages/pandas/lib.so in
  22. > pandas.lib.map_infer (pandas/lib.c:52281)()
  23. >
  24. > <ipython-input-53-01e79de1cb39> in <lambda>(x)
  25. > ----> 1 df['Avg. Session Duration'] = df['Avg. Session Duration'].apply(lambda x: x.split(':'))
  26. >
  27. > AttributeError: 'float' object has no attribute 'split'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement