Я пытаюсь масштабировать свою гистограмму с коэффициентом 0,1781628163, но постоянно получаю следующую ошибку: "IndexError: только целые числа, срезы (:
), многоточие (...
), numpy .newaxis (None
) и целые или логические массивы являются допустимыми индексами "
Вот мой код:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Konference = pd.read_csv(r'Daiichianden.csv')
Konference.hist(column='1.915844504072473',bins=400,range=[0,8])
xlo=0
xhi=8
nbins=180
data,bins = np.histogram(Konference['1.915844504072473'],bins=np.linspace(xlo,xhi,nbins))
KonferenceD = 0.1781628163*data
plt.title("Konference skaleret ift Daiichi")
plt.plot(bins,KonferenceD)
### Full error message
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-0ce3aceeb8cd> in <module>
6 KonferenceD = 0.1781628163*Konference
7 plt.title("Konference skaleret ift Daiichi")
----> 8 plt.plot(bins,KonferenceD)
/opt/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2793 return gca().plot(
2794 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2795 is not None else {}), **kwargs)
2796
2797
/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1664 """
1665 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
-> 1666 lines = [*self._get_lines(*args, data=data, **kwargs)]
1667 for line in lines:
1668 self.add_line(line)
/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in __call__(self, *args, **kwargs)
223 this += args[0],
224 args = args[1:]
--> 225 yield from self._plot_args(this, kwargs)
226
227 def get_next_color(self):
/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
389 x, y = index_of(tup[-1])
390
--> 391 x, y = self._xy_from_xy(x, y)
392
393 if self.command == 'plot':
/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
268 if x.shape[0] != y.shape[0]:
269 raise ValueError("x and y must have same first dimension, but "
--> 270 "have shapes {} and {}".format(x.shape, y.shape))
271 if x.ndim > 2 or y.ndim > 2:
272 raise ValueError("x and y can be no greater than 2-D, but have "
ValueError: x and y must have same first dimension, but have shapes (180,) and (179,)
----------
----------
### Converting the column into an array:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Konference = pd.read_csv(r'Daiichianden.csv')
a = np.loadtxt('Daiichianden.csv')
Konference.hist(column='1.915844504072473',bins=400,range=[0,8])
xlo=0
xhi=8
nbins=180
Konference,bins = np.histogram(a['1.915844504072473'],bins=np.linspace(xlo,xhi,nbins))
KonferenceD = 0.1781628163*Konference
plt.title("Konference skaleret ift Daiichi")
plt.plot(bins,KonferenceD)
### Full error message
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-18-37dcc7e9580c> in <module>
2 xhi=8
3 nbins=180
----> 4 Konference,bins = np.histogram(a['1.915844504072473'],bins=np.linspace(xlo,xhi,nbins))
5 KonferenceD = 0.1781628163*Konference
6 plt.title("Konference skaleret ift Daiichi")
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices