Closed
Description
addtl example / repro in #13908
Hello,
I encounter some problems using the data provided here: data.txt
When I was trying to use .loc on my DateTimeIndex, I go t the following error
KeyError: "['2015-03-01T02:00:00.000000000+0100'] not in index"
Notice that the error occurs only if we have the DST changing time in the DateTimeIndex
While debugging I've found that the error comes from the _convert_to_indexer method at:
# indexing.py
mask = check == -1
if mask.any():
raise KeyError('%s not in index' % objarr[mask]) <------------------------------------
Here is the copy-paste example using the data on the .txt attached:
data = pd.read_csv("data.txt"), parse_dates={'time':['Date']})
data.set_index('time', inplace=True)
data.index = data.index.tz_localize('Europe/Paris', ambiguous='infer').tz_convert('UTC')
for i in range(1, len(data)):
try:-aware
data.loc[data.index[:i], 'value'] = -1
except Exception as e:
print i,e
break
Other important fact: the error occurs for pandas version 0.17.0 and 0.17.1. However, I've managed to make it work with an older version of pandas (0.16.2)
I hope this is explicit enough.
UPDATE
In[19]: pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.19.0-33-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 18.5
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.1
statsmodels: None
IPython: 4.0.0
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: 2.4.6
matplotlib: 1.5.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None