Reputation: 1352
I am working with a dataframe loading from a CSV
.
Below is the link for the dataset:
https://drive.google.com/open?id=1emA29M1lO3q-2YQOhegKRsAdlydBkgh6
I created a sample example for the same procedure. It worked. But when I tried with the data set, an error pops up as follow:
TypeError: ufunc 'multiply' did not contain a loop with signature matching
types dtype('<U32') dtype('<U32') dtype('<U32')
I am running random calculation for 10 times for each row in dataframe.
for i in range(len(WC2018_Fix.HomeTeam)):
for j in range(0,10):
TeamA = WC2018_Fix.iloc[i,0]
TeamB = WC2018_Fix.iloc[i,1]
ELO_1 = np.array(WC2018_Fix.iloc[i,2])
ELO_2 = np.array(WC2018_Fix.iloc[i,3])
ELOA = random.random()*ELO_1
ELOB = random.random()*ELO_2
Can anyone advise what is going on?
Upvotes: 1
Views: 98
Reputation: 1382
In your loop, you can check the format/type of the values you read in. While multiplying if the expected cell value is not int/float you could type cast and then do it.
for i in range(len(WC2018_Fix.HomeTeam)):
for j in range(0,10):
TeamA = WC2018_Fix.iloc[i,0]
TeamB = WC2018_Fix.iloc[i,1]
if WC2018_Fix.iloc[i,2].__class__ == str:
var = int(WC2018_Fix.iloc[i,2]) # Convert accordingly to int
if WC2018_Fix.iloc[i,3].__class__ == str:
var2 = int(WC2018_Fix.iloc[i,3])
ELO_1 = np.array(var)
ELO_2 = np.array(var2)
ELOA = random.random()*ELO_1
ELOB = random.random()*ELO_2
Upvotes: 1