Python '<';在';str';和';int';,但是在数据中找不到字符串
我发现了这个错误Python '<';在';str';和';int';,但是在数据中找不到字符串,python,dataframe,error-handling,Python,Dataframe,Error Handling,我发现了这个错误“你能举一个数据帧的小例子吗?总是把完整的错误信息(从单词“Traceback”开始)作为文本(不是截图)放在问题中(不是评论)。还有其他有用的信息。很抱歉最后的答案。我包括了完整的错误和部分数据帧。你能举一个数据帧的小例子吗?总是把完整的错误消息(从单词“Traceback”开始)作为文本(不是截图)放在问题中(不是评论)。还有其他有用的信息。很抱歉最后的答案。我包括了全部错误和部分数据帧。 zi_diff_2017 = data_red_tot.iloc[:,2:6][(da
“你能举一个数据帧的小例子吗?总是把完整的错误信息(从单词“Traceback”开始)作为文本(不是截图)放在问题中(不是评论)。还有其他有用的信息。很抱歉最后的答案。我包括了完整的错误和部分数据帧。你能举一个数据帧的小例子吗?总是把完整的错误消息(从单词“Traceback”开始)作为文本(不是截图)放在问题中(不是评论)。还有其他有用的信息。很抱歉最后的答案。我包括了全部错误和部分数据帧。
zi_diff_2017 = data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2017)].subtract(data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2016)])
zi_diff_2018 = data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2018)].subtract(data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2017)])
zi_diff_2016 = data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2016)].subtract(data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2015)])
data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2016)].info()
<class 'pandas.core.frame.DataFrame'>
Index: 431 entries, 1 to 9866
Data columns (total 4 columns):
b 431 non-null float64
s 431 non-null float64
si 431 non-null float64
i 431 non-null float64
dtypes: float64(4)
memory usage: 16.8+ KB
data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2017)].info()
<class 'pandas.core.frame.DataFrame'>
Index: 431 entries, 1 to 9866
Data columns (total 4 columns):
b 431 non-null float64
s 431 non-null float64
si 431 non-null float64
i 431 non-null float64
dtypes: float64(4)
memory usage: 16.8+ KB
Traceback (most recent call last):
File "<ipython-input-219-66f6f768e275>", line 1, in <module>
zi_diff_2017 = data_red_tot.iloc[:,2:6][(data_red_tot["jahr"] == 2017)].subtract(data_red_tot.iloc[:,2:6][(data_red_tot["jahr"] == 2016)])
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\ops\__init__.py", line 1493, in f
return self._combine_frame(other, pass_op, fill_value, level)
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py", line 5359, in _combine_frame
this, other = self.align(other, join="outer", level=level, copy=False)
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py", line 3939, in align
broadcast_axis=broadcast_axis,
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py", line 8811, in align
fill_axis=fill_axis,
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py", line 8850, in _align_frame
other.index, how=join, level=level, return_indexers=True
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3572, in join
other, how=how, return_indexers=return_indexers
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3884, in _join_monotonic
join_index, lidx, ridx = self._outer_indexer(sv, ov)
File "C:\Users\BaranCalisci\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 247, in _outer_indexer
return libjoin.outer_join_indexer(left, right)
File "pandas\_libs\join.pyx", line 563, in pandas._libs.join.outer_join_indexer
TypeError: '<' not supported between instances of 'str' and 'int'
data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2017)]
Out[222]:
b s si i
mnr
1 76.420562 75.925346 80.022474 78.318538
1014 59.594468 72.901359 72.282378 60.533343
1036 61.411302 61.989852 72.520348 65.580230
1040 67.211456 70.899914 79.363689 75.096387
1061 50.524718 49.964110 73.015946 59.057265
... ... ... ...
9517 72.322934 68.839042 76.055376 74.890859
9519 58.167611 57.518538 65.719448 65.140976
964 72.290164 73.651271 74.162528 70.824842
968 51.930839 56.682868 63.408826 59.901983
9866 65.514969 59.013144 67.161826 69.747105
[431 rows x 4 columns]
data_red_tot.iloc[:,2:6][(data_red_tot["year"] == 2016)]
Out[223]:
b s si i
mnr
1 76.854202 74.451864 79.998974 78.063673
4 58.976897 67.254973 71.951488 71.543260
27 71.128836 64.647496 72.204597 71.105160
28 52.317802 66.144949 64.518158 63.351971
53 65.253281 55.666438 69.048888 68.434020
... ... ... ...
9517 53.312900 55.207277 67.526596 62.432935
9519 59.509448 61.668949 77.609081 66.764866
9519 59.509448 61.668949 77.609081 66.764866
9866 65.513959 61.555514 67.611603 71.011886
9866 65.513959 61.555514 67.611603 71.011886
[431 rows x 4 columns]