0

Even though I used bin my dataframe is not getting split into interval. Its gets split into a list.

Is it because of my version? I use Spyder Python-3.6

pressures = df.Pressure.value_counts(bins=10,dropna=True).index.values

pressures Out[505]:  array([  99.0252926,  112.15208  ,  138.27504  , 
157.86726  ,
        151.33652  ,  144.80578  ,  131.7443   ,  125.21356  ,
        118.68282  ,  105.62134  ])

pressures[0].left Traceback (most recent call last):

  File "<ipython-input-507-e9fa63a8a12f>", line 1, in <module>
    pressures[0].left

AttributeError: 'numpy.float64' object has no attribute 'left'

I would like to get it in form of an interval

Erfan
  • 40,971
  • 8
  • 66
  • 78

1 Answers1

0

It seems not the problem about python. Maybe you should update your pandas library.

Is this the result you want?

df['a'].value_counts(bins=2, dropna=True).index.values

array([Interval(0.45, 0.8, closed='right'),
       Interval(0.0983, 0.45, closed='right')], dtype=object)

Or you can show the result of df.Pressure.value_counts(bins=10,dropna=True).index to let us know what the result you want.

thisray
  • 36
  • 6