Skip to content

Instantly share code, notes, and snippets.

@Cally99
Created July 26, 2019 15:42
Show Gist options
  • Save Cally99/57262d45c7dc467ecbbc15ab0301caa2 to your computer and use it in GitHub Desktop.
Save Cally99/57262d45c7dc467ecbbc15ab0301caa2 to your computer and use it in GitHub Desktop.
IndexError Traceback (most recent call last)
<ipython-input-68-525af8799900> in <module>
5 return e_push_count.loc[e_push_count['mini_e'] < row['push_count']].iloc[-1]['percent_e']
6
----> 7 df2['push_count_score'] = df.apply(add_push_count, axis=1)
8
9
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, broadcast, raw, reduce, result_type, args, **kwds)
6485 args=args,
6486 kwds=kwds)
-> 6487 return op.get_result()
6488
6489 def applymap(self, func):
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\apply.py in get_result(self)
149 return self.apply_raw()
150
--> 151 return self.apply_standard()
152
153 def apply_empty_result(self):
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\apply.py in apply_standard(self)
255
256 # compute the result using the series generator
--> 257 self.apply_series_generator()
258
259 # wrap results
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\apply.py in apply_series_generator(self)
284 try:
285 for i, v in enumerate(series_gen):
--> 286 results[i] = self.f(v)
287 keys.append(v.name)
288 except Exception as e:
<ipython-input-68-525af8799900> in add_push_count(row)
3 return n_push_count.loc[n_push_count['mini_n'] < row['push_count']].iloc[-1]['percent_n']
4 elif row['deal_type'] == 'Expansion':
----> 5 return e_push_count.loc[e_push_count['mini_e'] < row['push_count']].iloc[-1]['percent_e']
6
7 df2['push_count_score'] = df.apply(add_push_count, axis=1)
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
1498
1499 maybe_callable = com.apply_if_callable(key, self.obj)
-> 1500 return self._getitem_axis(maybe_callable, axis=axis)
1501
1502 def _is_scalar_access(self, key):
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\indexing.py in _getitem_axis(self, key, axis)
2228
2229 # validate the location
-> 2230 self._validate_integer(key, axis)
2231
2232 return self._get_loc(key, axis=axis)
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\indexing.py in _validate_integer(self, key, axis)
2137 len_axis = len(self.obj._get_axis(axis))
2138 if key >= len_axis or key < -len_axis:
-> 2139 raise IndexError("single positional indexer is out-of-bounds")
2140
2141 def _getitem_tuple(self, tup):
IndexError: ('single positional indexer is out-of-bounds', 'occurred at index 0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment