Reputation: 959
import numpy as np
import pandas as pd
tempdata = np.random.random(10)
myseries = pd.Series(tempdata)
newseries = myseries[2:6]
Now if I put newseries in pd.Series and want to re-index(I know indexing is immutable) it with some alphabets I encounter following error.
According to pandas documentation Series can accept data as a Python dict or an ndarray or a scaler value
newseries = pd.Series(newseries, index = ['a','b','c','d'])
C:\Users\user110244\Anaconda3\lib\site-packages\pandas\formats\format.py:2191: RuntimeWarning: invalid value encountered in greater
has_large_values = (abs_vals > 1e6).any()
C:\Users\user110244\Anaconda3\lib\site-packages\pandas\formats\format.py:2192: RuntimeWarning: invalid value encountered in less
has_small_values = ((abs_vals < 10**(-self.digits)) &
C:\Users\user110244\Anaconda3\lib\site-packages\pandas\formats\format.py:2193: RuntimeWarning: invalid value encountered in greater
(abs_vals > 0)).any()
This error display continuously till I restart my Python.Even if try to execute some other simple command say
a = 2
the same error occured again. I just want to know why this is happening ? If I am wrong at some place then it will be better to display the error rather than continuously reoccurance of same thing. Is this a bug ? Please explain
My system details are:- Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] Win10 Pro
Upvotes: 0
Views: 377
Reputation: 3742
I don't get the same error. Since the indices 'a', 'b' etc are not in the orginal series, they get a NaN value, and the numbers are lost.
I think you want to discard the old index and start with a new one, So you can do
newseries = pd.Series(newseries.values, index = ['a','b','c','d'])
Upvotes: 1