Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Source Month Sessions Bounce Rate Avg. Session Duration
- ABC.com 201501 408 26.47% 0:03:26
- def time_convert(x):
- times = x.split(':')
- return (60*int(times[0])+60*int(times[1]))+int(times[2])
- df['Avg. Session Duration'] = df['Avg. Session Duration'].apply(time_convert)
- > --------------------------------------------------------------------------- AttributeError Traceback (most recent call
- > last) <ipython-input-53-01e79de1cb39> in <module>()
- > ----> 1 df['Avg. Session Duration'] = df['Avg. Session Duration'].apply(lambda x: x.split(':'))
- >
- > /Users/yumiyang/anaconda/lib/python2.7/site-packages/pandas/core/series.pyc
- > in apply(self, func, convert_dtype, args, **kwds) 1991
- > values = lib.map_infer(values, lib.Timestamp) 1992
- > -> 1993 mapped = lib.map_infer(values, f, convert=convert_dtype) 1994 if len(mapped) and
- > isinstance(mapped[0], Series): 1995 from
- > pandas.core.frame import DataFrame
- >
- > /Users/yumiyang/anaconda/lib/python2.7/site-packages/pandas/lib.so in
- > pandas.lib.map_infer (pandas/lib.c:52281)()
- >
- > <ipython-input-53-01e79de1cb39> in <lambda>(x)
- > ----> 1 df['Avg. Session Duration'] = df['Avg. Session Duration'].apply(lambda x: x.split(':'))
- >
- > AttributeError: 'float' object has no attribute 'split'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement