Home > Software design >  Ploting dataframe with NAs with linearly joined points
Ploting dataframe with NAs with linearly joined points

Time:08-31

I have a dataframe where each column has many missing values. How can I make a plot where the datapoints in each column are joined with lines, i.e. NAs are ignored, instead of having a choppy plot?

import numpy as np
import pandas as pd

pd.options.plotting.backend = "plotly"

d = pd.DataFrame(data = np.random.choice([np.nan]   list(range(7)), size=(10,3)))
d.plot(markers=True)

One way is to use this for each column:

fig = go.Figure()
fig.add_trace(go.Scatter(x=x, y=y, name="linear",
                    line_shape='linear'))

Are there any better ways to accomplish this?

CodePudding user response:

You can use pandas enter image description here

  • Related