Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- row_to_add = pd.MultiIndex.from_tuples()
- df.ix[row_to_add] = my_row
- >>> df = pd.DataFrame({'Time': [dt.datetime(2013,2,3,9,0,1), dt.datetime(2013,2,3,9,0,1)], 'hsec': [1,25], 'vals': [45,46]})
- >>> df
- Time hsec vals
- 0 2013-02-03 09:00:01 1 45
- 1 2013-02-03 09:00:01 25 46
- [2 rows x 3 columns]
- >>> df.set_index(['Time','hsec'],inplace=True)
- >>> ind = pd.MultiIndex.from_tuples([(dt.datetime(2013,2,3,9,0,2),0)],names=['Time','hsec'])
- >>> df.ix[ind] = 5
- Traceback (most recent call last):
- File "<pyshell#201>", line 1, in <module>
- df.ix[ind] = 5
- File "C:Program FilesPython27libsite-packagespandascoreindexing.py", line 96, in __setitem__
- indexer = self._convert_to_indexer(key, is_setter=True)
- File "C:Program FilesPython27libsite-packagespandascoreindexing.py", line 967, in _convert_to_indexer
- raise KeyError('%s not in index' % objarr[mask])
- KeyError: "[(Timestamp('2013-02-03 09:00:02', tz=None), 0L)] not in index"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement