Bar chart with timeseries index not displaying depending on proximity of the times
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 18.8k
- Fork
- 2.8k
- Merge medio
- 16h 26m
- PR unite (30g)
- 21
Descrizione
Found an issue causing a bar chart to display nothing when displaying timeseries data. It seems to be caused by having stacked data at two points which are very close in time (e.g. 12:00:00 and 12:00:01) and then one point much further away (e.g. 17:00:00).
import pandas as pd
import plotly.express as px
times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:01']
#times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00'] <-- works
vals = [10, 50, 20, 350, 250]
# Uncomment to cause bar chart to display no data
# times.append('2020-12-18 13:00:00')
# vals.append(1)
df = pd.DataFrame(list(zip(times, vals)),
columns =['DT', 'Val'])
df['DT'] = pd.to_datetime(df['DT'])
df = df.set_index('DT')
fig = px.bar(df, x=df.index, y=df['Val'])
fig.show()
- The code unchanged displays the figure fine

- If you uncomment the two append lines, adding in a data point which is further away, then the figure is empty

- If you uncomment the two append lines and changes the initial times list so that they are all :00, the figure displays fine

Therefore it seems to be caused by having points at 02:15:00 / 02:15:01 and then a point much later at 13:00:00
Thanks
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la riproduzione dell'issue con pandas e Plotly Express, prima con i timestamp ravvicinati e poi con il punto aggiuntivo 13:00:00. Confronta i dati della figura generata o il rendering in entrambi i casi; il lavoro è completato quando il grafico a barre visualizza i dati della serie temporale forniti nel caso che fallisce senza compromettere gli esempi funzionanti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- pandas, plotly, python
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100