I am successfully pulling data from a Fitbit sqlite db using Python sqlite3 as follows. I want to create Pandas scatter_matrix on the data.
My code that successfully gets data is:
import pandas.io.sql as psql
import sqlite3 as lite
from pandas.tools.plotting import scatter_matrix
con = lite.connect('C:/temp/fitbit-db')
sql = ('SELECT log_date,'
'duration,'
'minutes_to_fall_asleep,
'minutes_asleep,'
'minutes_awake,'
'minutes_after_wakeup,'
'awakenings_count,'
'time_in_bed,'
'awake_count,'
'efficiency,'
'restless_count '
'FROM sleep_log_entry')
cur.execute(sql)
I can print out the query results using:
fitbit_data_fetchall = cur.fetchall()
for row in fitbit_data_fetchall:
print row
Which looks gets rows like this:
(1397426400000L, 6420000, 8, 99, 0, 0, 0, 107, 0, 100.0, 0)
(1397944800000L, 23940000, 11, 370, 18, 0, 7, 399, 1, 95.0, 8)
(1399759200000L, 28200000, 13, 448, 9, 0, 2, 470, 0, 98.0, 2)
etc ....
But rather than just print rows I read query results into an array using:
fitbit_data_psql = psql.read_sql(sql, con)
I used this array with Pandas scatter_matrix to try to create the scatter matrix charts but its not working. I have tried a few variations such as:
scatter_matrix(fitbit_data_psql, alpha=0.2, figsize=(6, 6), diagonal='kde')
which seems to work without errors but only gets me 121 rows of the following but no charts. it takes a while to run so maybe timing out?
array([[<matplotlib.axes.AxesSubplot object at 0x0000000036798208>,
<matplotlib.axes.AxesSubplot object at 0x000000003681B6A0>,
<matplotlib.axes.AxesSubplot object at 0x000000003690BC50>,
<matplotlib.axes.AxesSubplot object at 0x0000000036A2DA20>,
<matplotlib.axes.AxesSubplot object at 0x0000000036947EF0>,
<matplotlib.axes.AxesSubplot object at 0x0000000036B88D68>,
<matplotlib.axes.AxesSubplot object at 0x0000000036C89710>,
etc ...
etc ...
<matplotlib.axes.AxesSubplot object at 0x00000000520FB978>,
<matplotlib.axes.AxesSubplot object at 0x00000000521E49E8>]], dtype=object)
I tried it with a few of the columns from array as follows:
scatter_matrix(fitbit_data_psql['activity', 'awake', 'asleep'], alpha=0.2, figsize=(6, 6), diagonal='kde')
But this gets the following error, looks like it doesn't recognize the columns?
KeyError Traceback (most recent call last)
<ipython-input-24-b0afbb6671fc> in <module>()
29 #scatter_matrix(fitbit_data, alpha=0.2, figsize=(6, 6), diagonal='kde')
30 #scatter_matrix(fitbit_data[['activity', 'awake', 'asleep']], figsize=(14, 10))
---> 31 scatter_matrix(fitbit_data['activity', 'awake', 'asleep'], alpha=0.2, figsize=(6, 6), diagonal='kde')
C:\Users\bb\Anaconda\lib\site-packages\pandas\core\frame.pyc in __getitem__(self, key)
1682 return self._getitem_multilevel(key)
1683 else:
-> 1684 return self._getitem_column(key)
1685
1686 def _getitem_column(self, key):
C:\Users\bb\Anaconda\lib\site-packages\pandas\core\frame.pyc in _getitem_column(self, key)
1689 # get column
1690 if self.columns.is_unique:
-> 1691 return self._get_item_cache(key)
1692
1693 # duplicate columns & possible reduce dimensionaility
C:\Users\bb\Anaconda\lib\site-packages\pandas\core\generic.pyc in _get_item_cache(self, item)
1050 res = cache.get(item)
1051 if res is None:
-> 1052 values = self._data.get(item)
1053 res = self._box_item_values(item, values)
1054 cache[item] = res
C:\Users\bb\Anaconda\lib\site-packages\pandas\core\internals.pyc in get(self, item)
2535
2536 if not isnull(item):
-> 2537 loc = self.items.get_loc(item)
2538 else:
2539 indexer = np.arange(len(self.items))[isnull(self.items)]
C:\Users\bb\Anaconda\lib\site-packages\pandas\core\index.pyc in get_loc(self, key)
1154 loc : int if unique index, possibly slice or mask if not
1155 """
-> 1156 return self._engine.get_loc(_values_from_object(key))
1157
1158 def get_value(self, series, key):
C:\Users\bb\Anaconda\lib\site-packages\pandas\index.pyd in pandas.index.IndexEngine.get_loc (pandas\index.c:3650)()
C:\Users\bb\Anaconda\lib\site-packages\pandas\index.pyd in pandas.index.IndexEngine.get_loc (pandas\index.c:3528)()
C:\Users\bb\Anaconda\lib\site-packages\pandas\hashtable.pyd in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:11908)()
C:\Users\bb\Anaconda\lib\site-packages\pandas\hashtable.pyd in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:11861)()
KeyError: ('activity', 'awake', 'asleep')
What is the correct usage of scatter_matrix with the array I have?
Updated questions:
I just realized the query results do not have header row, so that is likely why scatter_matrix isn't working. Does scatter_matrix work with relative column numbers?
Looks like the pandas.io.sql read_sql has some additional parameters to get column headers. I changed the read_sql statement from
fitbit_data_psql = psql.read_sql(sql, con)
to
fitbit_data_psql = psql.read_sql(sql, con, index_col=None, coerce_float=True)
and now the scatter_matrix plots are showing along with the column names as data labels.
Related
****I tried different methods and was following the guidance from that notebook, https://github.com/derekbanas/Python4Finance/blob/main/Python%20for%20Finance%2010.ipynb . However, it does't work and I don't know why. Please help. Thanks!
If you need more information, please let me know ****
tot_port_df = tot_port_df.asfreq('d')
tot_port_df.index
# Delete NaNs for nontrading days
tot_port_df = tot_port_df.fillna(method='ffill') # Fill in missing values using previous
# Delete all unneeded columns
del_col = ["PWR", "MCK", "ENPH", "GOOG", "COST", "ADM", "TSLA", "EXC",
"SIVB", "ALB", "IRM"]
for x in del_col:
tot_port_df = tot_port_df.drop([x], axis=1)
# Set style for seaborn plot
sns.set_style('darkgrid')
# Add automatic datetime converters
pd.plotting.register_matplotlib_converters()
# Default figure size
sns.mpl.rc('figure',figsize=(19, 13))
# Set fig and ax
fig, ax = plt.subplots()
# Figure out optimum lags for this data set
lags = ar_select_order(tot_port_df, maxlag=30)
print("Lags :", lags.ar_lags)
# Create our model using whole data set
model = AutoReg(tot_port_df['Total'], lags.ar_lags)
model_fit = model.fit()
# Define training and testing area
print("Observations :", len(tot_port_df)) # 856 observations
train_df = tot_port_df.iloc[0:685] # First 80%
test_df = tot_port_df.iloc[686:] # Last 20%
# Define training model for 459 days (Play with Number & Test)
# and White's covariance estimator
train_model = AutoReg(tot_port_df['Total'], 400).fit(cov_type="HC0")
# # Define start and end for prediction
start = len(train_df)
end = len(train_df) + len(test_df) - 1
prediction = train_model.predict(start=start, end=end, dynamic=True)
# Plot testing data with prediction
ax = test_df.plot(ax=ax) # Orange
ax = prediction.plot(ax=ax) # Green
# Predict 100 days into the future
forecast = train_model.predict(start=end, end=end+60, dynamic=True)
ax = forecast.plot(ax=ax) # Green```
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/var/folders/q8/qn3d11d90fbbz0j6kllhpn9h0000gn/T/ipykernel_50011/3923248969.py in <module>
12
13 for x in del_col:
---> 14 tot_port_df = tot_port_df.drop([x], axis=1)
15
16 # Set style for seaborn plot
~/opt/anaconda3/lib/python3.9/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)
312
313 return wrapper
~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py in drop(self, labels, axis, index, columns, level, inplace, errors)
4952 weight 1.0 0.8
4953 """
-> 4954 return super().drop(
4955 labels=labels,
4956 axis=axis,
~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)
4265 for axis, labels in axes.items():
4266 if labels is not None:
-> 4267 obj = obj._drop_axis(labels, axis, level=level, errors=errors)
4268
4269 if inplace:
~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py in _drop_axis(self, labels, axis, level, errors, consolidate, only_slice)
4309 new_axis = axis.drop(labels, level=level, errors=errors)
4310 else:
-> 4311 new_axis = axis.drop(labels, errors=errors)
4312 indexer = axis.get_indexer(new_axis)
4313
~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py in drop(self, labels, errors)
6642 if mask.any():
6643 if errors != "ignore":
-> 6644 raise KeyError(f"{list(labels[mask])} not found in axis")
6645 indexer = indexer[~mask]
6646 return self.delete(indexer)
KeyError: "['PWR'] not found in axis"
My previous script using OSMNX from Geoff boeing is not working anymore since I did Conda update. It used to run before. This is the bare part of the script that gives the error message
import osmnx as ox
import pandas as pd
import geopandas as gpd
import networkx as nx
import numpy as np
# Set place and language; It must return a POLYGON/POLYLINE, not a POINT, so you might have to play with it a little, or set which_result below accordingly
place='ALmere, Netherlands'
# note the which_result parameter, as per comment above. Default which_result=1. For places like Utrecht changing it gives a different result
G = ox.graph_from_place(place, network_type='all', which_result=1)
# For the colouring, we take the attributes from each edge found extract the road name, and use the function above to create the colour array
edge_attributes = ox.graph_to_gdfs(G, nodes=False)
Gives error message:
TypeError: unhashable type: 'dict'
I seem to have the last version of Osmnx (conda list shows 0.16.1). I did find this question, but can't translate that to my code: TypeError: unhashable type: 'dict' in Networkx random walk code that was previously working
And this one: https://github.com/gboeing/osmnx/issues/372. My Python version is 3.8.5
Traceback below:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-6a868604da3b> in <module>
10
11 # note the which_result parameter, as per comment above. Default which_result=1. For places like Utrecht changing it gives a different result
---> 12 G = ox.graph_from_place(place, network_type='all', which_result=1)
13
14 # For the colouring, we take the attributes from each edge found extract the road name, and use the function above to create the colour array
~\Anaconda3\lib\site-packages\osmnx\core.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery, infrastructure, custom_filter)
1443 max_query_area_size=max_query_area_size,
1444 clean_periphery=clean_periphery, infrastructure=infrastructure,
-> 1445 custom_filter=custom_filter)
1446
1447 log('graph_from_place() returning graph with {:,} nodes and {:,} edges'.format(len(list(G.nodes())), len(list(G.edges()))))
~\Anaconda3\lib\site-packages\osmnx\core.py in graph_from_polygon(polygon, network_type, simplify, retain_all, truncate_by_edge, name, timeout, memory, max_query_area_size, clean_periphery, infrastructure, custom_filter)
1319 G_buffered = create_graph(response_jsons, name=name, retain_all=True,
1320 bidirectional=network_type in settings.bidirectional_network_types)
-> 1321 G_buffered = truncate_graph_polygon(G_buffered, polygon_buffered, retain_all=True, truncate_by_edge=truncate_by_edge)
1322
1323 # simplify the graph topology
~\Anaconda3\lib\site-packages\osmnx\core.py in truncate_graph_polygon(G, polygon, retain_all, truncate_by_edge, quadrat_width, min_num, buffer_amount)
731
732 # find all the nodes in the graph that lie outside the polygon
--> 733 points_within_geometry = intersect_index_quadrats(gdf_nodes, polygon, quadrat_width=quadrat_width, min_num=min_num, buffer_amount=buffer_amount)
734 nodes_outside_polygon = gdf_nodes[~gdf_nodes.index.isin(points_within_geometry.index)]
735
~\Anaconda3\lib\site-packages\osmnx\core.py in intersect_index_quadrats(gdf, geometry, quadrat_width, min_num, buffer_amount)
678 # drop duplicate points, if buffered poly caused an overlap on point(s)
679 # that lay directly on a quadrat line
--> 680 points_within_geometry = points_within_geometry.drop_duplicates(subset='node')
681 else:
682 # after simplifying the graph, and given the requested network type,
~\Anaconda3\lib\site-packages\pandas\core\frame.py in drop_duplicates(self, subset, keep, inplace, ignore_index)
5106
5107 inplace = validate_bool_kwarg(inplace, "inplace")
-> 5108 duplicated = self.duplicated(subset, keep=keep)
5109
5110 result = self[-duplicated]
~\Anaconda3\lib\site-packages\pandas\core\frame.py in duplicated(self, subset, keep)
5245
5246 vals = (col.values for name, col in self.items() if name in subset)
-> 5247 labels, shape = map(list, zip(*map(f, vals)))
5248
5249 ids = get_group_index(labels, shape, sort=False, xnull=False)
~\Anaconda3\lib\site-packages\pandas\core\frame.py in f(vals)
5220 def f(vals):
5221 labels, shape = algorithms.factorize(
-> 5222 vals, size_hint=min(len(self), _SIZE_HINT_LIMIT)
5223 )
5224 return labels.astype("i8", copy=False), len(shape)
~\Anaconda3\lib\site-packages\pandas\core\algorithms.py in factorize(values, sort, na_sentinel, size_hint)
676
677 codes, uniques = _factorize_array(
--> 678 values, na_sentinel=na_sentinel, size_hint=size_hint, na_value=na_value
679 )
680
~\Anaconda3\lib\site-packages\pandas\core\algorithms.py in _factorize_array(values, na_sentinel, size_hint, na_value, mask)
499 table = hash_klass(size_hint or len(values))
500 uniques, codes = table.factorize(
--> 501 values, na_sentinel=na_sentinel, na_value=na_value, mask=mask
502 )
503
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.factorize()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable._unique()
TypeError: unhashable type: 'dict'
A variation of this post, without the detailed traceback, had been posted in the SO about two hours ago. This version contains the whole traceback.)
I am running StatsModels to get parameter estimates from ordinary least-squares (OLS). Data-processing and model-specific commands are shown below. When I use import statsmodels.formula.api as smas the operative api, the OLS works as desired (after I drop some 15 rows programmatically), giving intuitive results. But when I switch to import statsmodels.api as sm as the binding api, without changing the code almost at all, things fall apart, and Python interpreter triggers an error saying that 'inc_2 is not in the index'. Mind you, inc_2 was computed after the dataframe was read into StatsModels in both model runs: and yet the run was successful in the first, but not in the second. (BTW, p_c_inc_18 is per-capita income, and inc_2 is the former squarred. inc_2 is the offensive element in the second run.)
import pandas as pd
import numpy as np
import statsmodels.api as sm
%matplotlib inline import
matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="whitegrid") eg=pd.read_csv(r'C:/../../../une_edu_pipc_06.csv') pd.options.display.precision = 3
plt.rc("figure", figsize=(16,8))
plt.rc("font", size=14)
sm_col = eg["lt_hsd_17"] + eg["hsd_17"]
eg["ut_hsd_17"] = sm_col
sm_col2 = eg["sm_col_17"] + eg["col_17"] eg["bnd_hsd_17"] = sm_col2
eg["d_09"]= eg["Rate_09"]-eg["Rate_06"]
eg["d_10"]= eg["Rate_10"]-eg["Rate_06"] inc_2=eg["p_c_inc_18"]*eg["p_c_inc_18"]
X = eg[["p_c_inc_18","ut_hsd_17","d_10","inc_2"]]
y = eg["Rate_18"]
X = sm.add_constant(X)
mod = sm.OLS(y, X)
res = mod.fit()
print(res.summary())
Here is the traceback in full.
KeyError Traceback (most recent call last)
<ipython-input-21-e2f4d325145e> in <module>
17 eg["d_10"]= eg["Rate_10"]-eg["Rate_06"]
18 inc_2=eg["p_c_inc_18"]*eg["p_c_inc_18"]
---> 19 X = eg[["p_c_inc_18","ut_hsd_17","d_10","inc_2"]]
20 y = eg["Rate_18"]
21 X = sm.add_constant(X)
~\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2804 if is_iterator(key):
2805 key = list(key)
-> 2806 indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1]
2807
2808 # take() does not accept boolean indexers
~\Anaconda3\lib\site-packages\pandas\core\indexing.py in _get_listlike_indexer(self, key, axis, raise_missing)
1550 keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr)
1551
-> 1552 self._validate_read_indexer(
1553 keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
1554 )
~\Anaconda3\lib\site-packages\pandas\core\indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
1644 if not (self.name == "loc" and not raise_missing):
1645 not_found = list(set(key) - set(ax))
-> 1646 raise KeyError(f"{not_found} not in index")
1647
1648 # we skip the warning on Categorical/Interval
KeyError: "['inc_2'] not in index"
What am I doing wrong?
The syntax you used insists that a list of strings is a legal index into eg. If you print(eg), you'll see that it has no such element. I think what you meant was to make a list of elements, each indexed by a single string.
X = [
eg["p_c_inc_18"],
eg["ut_hsd_17"],
eg["d_10"],
eg["inc_2"]
]
I want to initializes a dataframe and set its column and index as shown below but I face some issues while do like this:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
record = pd.DataFrame(MAE, columns=dataset, index=classifier).transpose()
plt.figure(figsize=(8, 8))
plt.title('MAE HeatMap Dataset vs Classifier')
sns.heatmap(record, linewidths=0.5, annot=True)
plt.show()
From above Matrix define as:
before Update:
MAE = [[[0], [0], [0]],
[[0], [0], [0]]]
After Update:
MAE = [[array([ 27.5]), array([ 29.9]), array([ 37.8])],
[array([ 6.51]), array([ 7.51]), array([ 9.81])]]
and dataset as:
da = ['Xtrain','Ytrain']
and cl as:
classifier = ['Ax','Bx','Cx']
following error is occur while executing this line:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-45-f0449c7e5b93> in <module>()
43 return
44
---> 45 main()
<ipython-input-45-f0449c7e5b93> in main()
29 DisplayWTL(dataset[city] + ' R2 Score', WTL_R2[0], classifier)
30
---> 31 record = pd.DataFrame(MAE, columns=dataset, index=classifier).transpose()
32 plt.figure(figsize=(8, 8))
33 plt.title('MAE HeatMap Dataset vs Classifier')
/home/AAK/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
303 if is_named_tuple(data[0]) and columns is None:
304 columns = data[0]._fields
--> 305 arrays, columns = _to_arrays(data, columns, dtype=dtype)
306 columns = _ensure_index(columns)
307
/home/AAK/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in _to_arrays(data, columns, coerce_float, dtype)
5517 if isinstance(data[0], (list, tuple)):
5518 return _list_to_arrays(data, columns, coerce_float=coerce_float,
-> 5519 dtype=dtype)
5520 elif isinstance(data[0], collections.Mapping):
5521 return _list_of_dict_to_arrays(data, columns,
/home/AAK/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in _list_to_arrays(data, columns, coerce_float, dtype)
5596 content = list(lib.to_object_array(data).T)
5597 return _convert_object_array(content, columns, dtype=dtype,
-> 5598 coerce_float=coerce_float)
5599
5600
/home/AAK/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in _convert_object_array(content, columns, coerce_float, dtype)
5655 # caller's responsibility to check for this...
5656 raise AssertionError('%d columns passed, passed data had %s '
-> 5657 'columns' % (len(columns), len(content)))
5658
5659 # provide soft conversion of object dtypes
AssertionError: 2 columns passed, passed data had 3 columns
how to resolve this problem in python dataframe?
Looks like you try to set up the dataframe that contains three columns but you only specify 2 to the constructor. Change your column labels columns=dataset to count to three and you should be fine. Change to da = ['Xtrain', 'Ytrain', 'Smth_else'], for example.
The answer is simple:
reverse your list like this:
list(map(list, zip(*MAE)))
the code now look like this:
record = pd.DataFrame(list(map(list, zip(*MAE))), columns=dataset, index=classifier).transpose()
plt.figure(figsize=(8, 8))
plt.title('MAE HeatMap Dataset vs Classifier')
sns.heatmap(record, linewidths=0.5, annot=True)
plt.show()
I'm very new to Python so please excuse any stupidity on my part.
I'm running a histogram with matplotlib and getting errors when I use subset data, the code works perfectly if I use the full dataset, hence my confusion.
Perhaps I'm not subsetting correctly?
My code is below and related errors are below, thanks.
For awareness, this was written in Python 3.
Import required packages:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
Read the data:
mlb=pd.read_csv('C:\Users\ocmh\Desktop\Python\Batting.csv')
View a sample of the data:
mlb.head()
Subset the data to return just Boston data:
mlb_bos=mlb[(mlb['teamID'] == 'BOS')]
View a sample of the subset data:
mlb_bos.head()
Plot a histogram of the original data: And works perfectly
plt.hist(mlb.AB.dropna, color= sns.desaturate("indianred",1))
Plot a histogram of the subset data: Returns errors (Errors are below)
plt.hist(mlb_bos.AB.dropna, color= sns.desaturate("indianred",1))
If you don't have the seaborn package installed, you can just drop color= sns.desaturate("indianred",1) as this was purely for aesthetics.
Errors below:
KeyError Traceback (most recent call last)
<ipython-input-11-1484047d7ac6> in <module>()
----> 1 plt.hist(mlb_bos.AB, color=color)
/Users/mattoconnell/anaconda/lib/python3.4/site-packages/matplotlib/pyplot.py in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, hold, **kwargs)
2894 histtype=histtype, align=align, orientation=orientation,
2895 rwidth=rwidth, log=log, color=color, label=label,
-> 2896 stacked=stacked, **kwargs)
2897 draw_if_interactive()
2898 finally:
/Users/mattoconnell/anaconda/lib/python3.4/site-packages/matplotlib/axes/_axes.py in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
5602 # Massage 'x' for processing.
5603 # NOTE: Be sure any changes here is also done below to 'weights'
-> 5604 if isinstance(x, np.ndarray) or not iterable(x[0]):
5605 # TODO: support masked arrays;
5606 x = np.asarray(x)
/Users/mattoconnell/anaconda/lib/python3.4/site-packages/pandas/core/series.py in __getitem__(self, key)
512 def __getitem__(self, key):
513 try:
--> 514 result = self.index.get_value(self, key)
515
516 if not np.isscalar(result):
/Users/mattoconnell/anaconda/lib/python3.4/site-packages/pandas/core/index.py in get_value(self, series, key)
1458
1459 try:
-> 1460 return self._engine.get_value(s, k)
1461 except KeyError as e1:
1462 if len(self) > 0 and self.inferred_type in ['integer','boolean']:
pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3113)()
pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:2844)()
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:3704)()
pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:7255)()
pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:7193)()
KeyError: 0