kikee1222
kikee1222

Reputation: 2016

problems with panda dataframe type

Can anyone help me to understand what I need to do to fix this

The input is a list of domains or IP addresses, so can be strings, numbers, anything really

I've tried to get around the problem by casting as string, but no luck!

Any help would be great


TypeError                                 Traceback (most recent call last)
<ipython-input-7-6c3a37053f0a> in <module>()
     16   for x in index:
     17     #if it ends with a number, it's an IP
---> 18     if str(x[len(str(x)-1)]).isnumeric():
     19       cleandomain.append(str(x[0])+'.'+str(x[1])+'.*.*')
     20     #if its in the CDN list, take a subdomain as well

TypeError: unsupported operand type(s) for -: 'str' and 'int'

Upvotes: 1

Views: 49

Answers (1)

Sjoseph
Sjoseph

Reputation: 873

The problem is in this line

len(str(x)-1)

Change it to

len(str(x))-1

In your code you were attempting to subtract 1 from a string, hence the error.

Upvotes: 4

Related Questions