- data4_pivot['total_duration'] = round(data4_pivot['total_duration'], 0)
- def money(subscription_type):
- if subscription_type == 'ultra':
- return data4_pivot['total_duration'] * 6 + data4_pivot['subscription_type'].count() * 199
- if subscription_type == 'free':
- return data4_pivot['total_duration']* 8 + data4_pivot['trip_count'].count() * 50
- data4_pivot['money'] = data4_pivot['subscription_type'].apply(money, axis=1)
- ---------------------------------------------------------------------------
- TypeError Traceback (most recent call last)
- /tmp/ipykernel_79/156564176.py in <module>
- 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)
- /opt/conda/lib/python3.9/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
- 4136 else:
- 4137 values = self.astype(object)._values
- -> 4138 mapped = lib.map_infer(values, f, convert=convert_dtype)
- 4139
- 4140 if len(mapped) and isinstance(mapped[0], Series):
- pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
- /opt/conda/lib/python3.9/site-packages/pandas/core/series.py in f(x)
- 4121
- 4122 def f(x):
- -> 4123 return func(x, *args, **kwds)
- 4124
- 4125 else:
- TypeError: money() got an unexpected keyword argument 'axis'