I have a series which has only one value and i want to get that value only. I ran a code to get t he value by index matching and i got a series like this:
(normal_sum['KWH'][(normal_sum['KWH'].index == date)])
Timestamp
2017-04-02 2934.93
Freq: D, Name: KWH, dtype: float64
But when i tried to convert it into a float by this:
float(normal_sum['KWH'][(normal_sum['KWH'].index == date)])
It is throwing an error:
TypeError: cannot convert the series to <type 'float'>
Expected output: 2934.93
Any help would be appreciated.
There is an edit:
I am facing another problem:
Suppose i get an empty series then how can i convert it to zero.
i did this:
(normal_sum['KWH'][(normal_sum['KWH'].index == date)])
Got a series like this:
Series([], Freq: D, Name: KWH, dtype: float64)
please help.