Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 TypeError: unsupported operand type(s) for -: 'str' and 'str'
#1
Hi,
I am new to python. I am trying to do some operation with my data set

I am trying to do this operation

df['dif_and_sq']=(df['imdbRating']).sub((df['imdbVotes']))
i am getting this error

Error:
TypeError: unsupported operand type(s) for -: 'str' and 'str'
Even i tried to convert the variable to numeric but its not converting a it remains in serious

If I tried like this

df['dif_and_sq']=int(df['imdbRating']).sub(int(df['imdbVotes']))
The error is

Error:
TypeError: cannot convert the series to <class 'int'>
how to reslove this error
Larz60+ wrote Oct-10-2019, 11:33 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote

Top Page

Messages In This Thread
TypeError: unsupported operand type(s) for -: 'str' and 'str' - by Balaji - Oct-10-2019, 06:05 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  TypeError: size; expecting a recognized type filling string dict a11_m11 0 174 Feb-10-2020, 08:26 AM
Last Post: a11_m11
  TypeError: type str doesn't define __round__ method emmapaw24 7 476 Feb-03-2020, 08:38 PM
Last Post: snippsat
  TypeError: can't multiply sequence by non-int of type 'str' emmapaw24 2 145 Feb-03-2020, 05:50 PM
Last Post: michael1789
  Type hinting - return type based on parameter micseydel 2 148 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Need help with "unsupported operand type(s)" _dave 6 839 Oct-14-2019, 06:43 AM
Last Post: buran
  TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str' findbikash 2 643 Sep-18-2019, 08:32 AM
Last Post: buran
  Type Error: bad operand type for unary +: 'str' Psypher1 2 2,843 Aug-12-2019, 02:30 PM
Last Post: Psypher1
  TypeError: can't multiply sequence by non-int of type 'str' rregorr 2 513 Jun-28-2019, 04:43 PM
Last Post: Yoriz
  TypeError: object of type 'NoneType' has no len() - what do it mean? leviathan54 4 2,978 Apr-20-2019, 12:04 PM
Last Post: leviathan54
  please help me TypeError: unsupported operand type(s) for +=: 'int' and 'list' aankrose 2 1,914 Mar-26-2019, 06:00 PM
Last Post: perfringo

Forum Jump:


Users browsing this thread: 1 Guest(s)