Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Type Error in Python
#1
Why do I get
"TypeError: can't multiply sequence by non-int of type 'float'" with the code below?


#add ranges to list of tuple pairs
ranges = []
a_values = []
b_values = []

for x in params:
    a = min(df[params][x])
    a = a - (a*.25)
    
    b = max(df[params][x])
    b = b + (b*.25)
    
    ranges.append((a,b))
    
for x in range(len(df['Player'])):
    if df['Player'][x] == 'Bruno Fernandes':
        a_values = df.iloc[x].values.tolist()
    if df['Player'][x] == 'K. De Bruyne':
        b_values = df.iloc[x].values.tolist()
        
a_values = a_values[1:]
b_values = b_values[1:]

values = [a_values,b_values]
buran write Mar-30-2021, 06:17 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
what is df? what is params? Also post full traceback in error tags.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Mar-30-2021, 06:19 PM)buran Wrote: what is df? what is params? Also post full traceback in error tags.

Sorry, I'm very new to this whole coding thing. Df = Data frame. Params = Parameters

Full traceback: ---------------------------------------------------------------------------
Error:
TypeError Traceback (most recent call last) <ipython-input-10-6c367cbca7e0> in <module> 6 for x in params: 7 a = min(df[params][x]) ----> 8 a = a - (a*.25) 9 10 b = max(df[params][x])
TypeError: can't multiply sequence by non-int of type 'float'
buran write Mar-30-2021, 06:34 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#4
(Mar-30-2021, 06:23 PM)MarcusB Wrote: Df = Data frame. Params = Parameters
We can guess that. The question is what are their values.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Wrong type error rowan_bradley 6 1,229 Aug-07-2023, 10:44 AM
Last Post: rowan_bradley
  Type Error: Unsupported Operand jhancock 2 1,201 Jul-22-2023, 11:33 PM
Last Post: jhancock
  Python Anytree - Is not of type 'NodeMixin' error georgebijum 3 2,096 May-05-2022, 01:43 PM
Last Post: Gribouillis
  Incorrect Type Error milkycow 4 2,912 Jun-25-2021, 06:04 AM
Last Post: milkycow
Star Type Error: 'in' object is not callable nman52 3 3,417 May-01-2021, 11:03 PM
Last Post: nman52
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,096 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  unsupported operand type(s) for /: 'str' and 'int' Error for boxplot soft 1 3,068 Feb-09-2021, 05:40 PM
Last Post: soft
  Type Error or Value Error? spalisetty06 3 2,398 Jul-21-2020, 04:56 AM
Last Post: deanhystad
  Type error: '>' not supported between instances of 'NoneType' and 'int' spalisetty06 1 10,488 Apr-29-2020, 06:41 AM
Last Post: buran
  Data Type conversion error rajeevjagatap 2 4,352 Apr-15-2020, 03:29 PM
Last Post: rajeevjagatap

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020