Reputation: 31
time_weight = list(100*np.exp(np.linspace(-1/divisor, -(num_steps-1)/divisor, num_steps))).apply(lambda x:int(x))
When I try this, I get the following error in Python 3.7.
AttributeError: 'list' object has no attribute 'apply'
Can anyone help with this?
Upvotes: 3
Views: 24360
Reputation:
As the error said, list
type has no apply
attribute.
This said, if you have a list l
and you want to set to int
type every element in it you may use:
l = [int(x) for x in l]
or
l = list(map(int,l))
Upvotes: 6
Reputation: 14536
As the error suggests, list
has no apply
method. If what you want to do is convert every element to an int
, you could remove the lambda function and instead use astype(int)
:
time_weight = list((100*np.exp(np.linspace(-1/divisor, -(num_steps-1)/divisor, num_steps))).astype(int))
Upvotes: 0