hv.Points(df) with duplicate columns in dataframe
See original GitHub issueThe 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:
print(hv.__version__) # 1.9.4-x-g73c2735e7
print(pd.__version__) # 0.20.3
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.