0
Ich erhalte:Wie kann ich vermeiden oder Abhilfe: Typeerror: nicht unterstützte Operandtyp (e) für: - 'float' und 'str'
TypeError: unsupported operand type(s) for -: 'float' and 'str'
in:
line 525, in <module>
df3['D'] = df3['O2'].sub(df3['O1'], fill_value=0)
File "C:\Users\AC\AppData\Local\Continuum\miniconda3\lib\site-packages\pandas\core\ops.py", line 1070, in flex_wrapper
return self._binop(other, op, level=level, fill_value=fill_value)
File "C:\Users\AC\AppData\Local\Continuum\miniconda3\lib\site-packages\pandas\core\series.py", line 1715, in _binop
result = func(this_vals, other_vals)
TypeError: unsupported operand type(s) for -: 'float' and 'str'
In:
df1 = pd.read_csv('C:\13.csv',
index_col=False,
usecols=[0, 1, 2, 3],
names=["EW", "WE", "DA", "DD"],
header=None)
# print(df1.head())
df2 = pd.read_csv('C:\\14.csv',
index_col=False,
usecols=[0, 1, 2, 3, 4],
names=["AA", "AB", "AC", "AD", "AE"],
header=None)
df1['EW'] = df1['EW'] + ' v ' + df1['WE']
df1['WE'] = df1['DA']
df1['DA'] = df1['DD']
df2['EW'] = df2['AB'] + ' v ' + df2['AC']
df2['EW'] = df2['AB'] + ' v ' + df2['AC']
df3 = pd.merge(df2, df1, on='EW')
df3 = df3.rename(columns={'WE': 'O1', 'AD': 'O2'})
df3['D'] = df3['O2'].sub(df3['O1'], fill_value=0)
Meine Datenrahmen wie folgt aussehen:
EW WE DA \
0 KV Mechelen Club Brugge 4.30
1 Gent Charleroi 1.75
2 Royal Antwerp Lokeren 1.68
3 Anderlecht Eupen 1.31
4 Waasland-Beveren Oostende 2.20
DD
0 https://www.topsport.com.au/Soccer/Belgian_Jup...
1 https://www.topsport.com.au/Soccer/Belgian_Jup...
2 https://www.topsport.com.au/Soccer/Belgian_Jup...
3 https://www.topsport.com.au/Soccer/Belgian_Jup...
4 https://www.topsport.com.au/Soccer/Belgian_Jup...
AA AB AC AD \
0 Thu 18:50 Brisbane Roar Perth Glory 2.24
1 Dec 22 18:50 Newcastle Jets Western Sydney Wanderers 2.42
2 Dec 23 16:35 Wellington Phoenix Sydney 7.20
3 Dec 23 18:50 Melbourne City Melbourne Victory 3.00
4 Dec 26 18:50 Adelaide United Central Coast Mariners 2.14
AE
0 https://www.betfair.com.au/exchange/plus/footb...
1 https://www.betfair.com.au/exchange/plus/footb...
2 https://www.betfair.com.au/exchange/plus/footb...
3 https://www.betfair.com.au/exchange/plus/footb...
4 https://www.betfair.com.au/exchange/plus/footb...
Wie vermeide ich diesen Fehler, die auftauchen hält?
erhalte ich: https://pastebin.com/szuF7QMA –
Warten Sie nie, ich denke, dass behoben –
Es ist falsch eingefügt Code, müssen nach dem Umbenennen zu 'O1', überprüfen Sie bearbeiten. – jezrael