Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug clearing Buffer stream when streaming dataframe with index #2952

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ def update(self, **kwargs):
"""
data = kwargs.get('data')
if data is not None:
if util.pd and isinstance(data, util.pd.DataFrame) and self._index:
if (util.pd and isinstance(data, util.pd.DataFrame) and
list(data.columns) != list(self.data.columns) and self._index):
data = data.reset_index()
self.verify(data)
kwargs['data'] = self._concat(data)
Expand Down
6 changes: 6 additions & 0 deletions tests/teststreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,9 @@ def test_buffer_dframe_send_verify_column_fail(self):
error = "Input expected to have columns \['x', 'y'\], got \['x'\]"
with self.assertRaisesRegexp(IndexError, error):
buff.send(pd.DataFrame({'x': np.array([2])}))

def test_clear_buffer_dframe_with_index(self):
data = pd.DataFrame({'a': [1, 2, 3]})
buff = Buffer(data)
buff.clear()
self.assertEqual(buff.data, data.iloc[:0, :].reset_index())