Untitled

From Idiotic Earthworm, 5 Months ago, written in Plain Text, viewed 142 times.
URL http://codebin.org/view/a0db32a4 Embed
Download Paste or View Raw
  1. data4_pivot['total_duration'] = round(data4_pivot['total_duration'], 0)
  2. def money(subscription_type):
  3.     if subscription_type == 'ultra':
  4.         return data4_pivot['total_duration'] * 6 + data4_pivot['subscription_type'].count() * 199
  5.     if subscription_type == 'free':
  6.         return data4_pivot['total_duration']* 8 + data4_pivot['trip_count'].count() * 50
  7. data4_pivot['money'] = data4_pivot['subscription_type'].apply(money, axis=1)
  8.  
  9.  
  10. ---------------------------------------------------------------------------
  11. TypeError                                 Traceback (most recent call last)
  12. /tmp/ipykernel_79/156564176.py in <module>
  13.       5     if subscription_type == 'free':
  14.       6         return data4_pivot['total_duration']* 8 + data4_pivot['trip_count'].count() * 50
  15. ----> 7 data4_pivot['money'] = data4_pivot['subscription_type'].apply(money, axis=1)
  16.  
  17. /opt/conda/lib/python3.9/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
  18.    4136             else:
  19.    4137                 values = self.astype(object)._values
  20. -> 4138                 mapped = lib.map_infer(values, f, convert=convert_dtype)
  21.    4139
  22.    4140         if len(mapped) and isinstance(mapped[0], Series):
  23.  
  24. pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
  25.  
  26. /opt/conda/lib/python3.9/site-packages/pandas/core/series.py in f(x)
  27.    4121
  28.    4122             def f(x):
  29. -> 4123                 return func(x, *args, **kwds)
  30.    4124
  31.    4125         else:
  32.  
  33. TypeError: money() got an unexpected keyword argument 'axis'

Reply to "Untitled"

Here you can reply to the paste above