2015-08-22, 12:15 PM - X: bla bla
2015-08-22, 12:15 PM - Y: bla
2015-08-22, 12:16 PM - Y: blabla
2015-08-22, 12:17 PM - X: bla
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2656 try:
-> 2657 return self._engine.get_loc(key)
2658 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'date'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-4-5e2de28f6c26> in <module>
----> 1 chat = WhatsAppChat.from_txt(filename)
~/whatstk/whatstk/objects.py in from_txt(cls, filename, auto_header, hformat, encoding)
44 hformat.replace('[', '\[').replace(']', '\]')
45 # Prepare DataFrame
---> 46 df = cls._prepare_df(text, hformat)
47
48 return cls(df)
~/whatstk/whatstk/objects.py in _prepare_df(text, hformat)
79
80 # Parse chat to DataFrame
---> 81 df = parse_chat(text, r)
82
83 # get rid of wp warning messages
~/whatstk/whatstk/utils/parser.py in parse_chat(text, regex)
51 line_dict = _parse_line(text, headers, i)
52 result.append(line_dict)
---> 53 df_chat = pd.DataFrame.from_records(result, index='date')
54 return df_chat[['username', 'message']]
55
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py in from_records(cls, data, index, exclude, columns, coerce_float, nrows)
1527 if (isinstance(index, compat.string_types) or
1528 not hasattr(index, "__iter__")):
-> 1529 i = columns.get_loc(index)
1530 exclude.add(index)
1531 if len(arrays) > 0:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2657 return self._engine.get_loc(key)
2658 except KeyError:
-> 2659 return self._engine.get_loc(self._maybe_cast_indexer(key))
2660 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2661 if indexer.ndim > 1 or indexer.size > 1:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'date'