question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hv.Points(df) with duplicate columns in dataframe

See original GitHub issue

The user guide says dataframes are supported, but I’m having trouble in cases with duplicate columns. The error message is also not very helpful in pinpointing what is going wrong.

Also, API documentation for element.chart.Chart does not mention dataframes, not sure if it should.

import numpy as np
import pandas as pd
import holoviews as hv
data = pd.DataFrame(np.random.randint(-100,100, size=(100, 2)), columns=list("AB"))

# Dataframe with non-duplicate columns works
hv.Points(data[["A", "B"]])

# Dataframe with duplicate columns does not work.
hv.Points(data[["A", "A"]])

# Converting to the numpy array works
hv.Points(data[["A", "A"]].as_matrix())

The last part of the traceback: image

print(hv.__version__) # 1.9.4-x-g73c2735e7
print(pd.__version__) # 0.20.3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
philippjfrcommented, Mar 24, 2018

Having read up on the history a bit, I can sort of understand why pandas allows this. When reading in csv files with duplicate columns you don’t want it to fail or mutate your columns automatically. Anyway adding the exception in holoviews should be easy.

1reaction
philippjfrcommented, Mar 22, 2018

We could consider putting in a warning if we detect that happening, though?

Good idea, but I think it should be an exception tbh, there is no way we’ll be able to resolve which column is meant if it’s duplicated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

hv.Points(df) with duplicate columns in dataframe · Issue #2476
The user guide says dataframes are supported, but I'm having trouble in cases with duplicate columns. The error message is also not very ......
Read more >
How to Find & Drop duplicate columns in a Pandas DataFrame?
Method 2: Remove duplicate columns from a DataFrame using df.loc ... Pandas df.duplicated() method helps in analyzing duplicate values only.
Read more >
Interesting results with duplicate columns in pandas.DataFrame
df ['a'] = list(range(5)). This gives no error and seems to produce what you need: ... same for creating column c: df['c'] =...
Read more >
How to Create a Duplicate Column in Pandas DataFrame
This tutorial explains how to create a duplicate column in a pandas DataFrame, including an example.
Read more >
Remove duplicate columns by name in Pandas - InterviewQs
#create a dataframe raw_data = {'name': ['Willard Morris', 'Al Jennings'], 'age': [20, 19], ... #preview the df df = df.loc[:,~df.columns.duplicated()] df ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found