0

I have the following grouped dataset:

dataset.groupby(['Date',"Product"]).count()
                        Product Code      Description
Date         Product
2019-01-03     A            1              1
               B            3              3 
               C            NaN            NaN
2019-01-04     A            8              8
               B            NaN            NaN 
               C            NaN            NaN
2019-01-11     A            NaN            NaN
               B            4              4
               C            5              5

The dataset groups three products and counts the number of occurrences grouped by date and these products. Some date information might be missing, for example 2019-01-05.

I would like to create a timeseries plot, in which the missing data values are plotted as 0 and the products are plotted in a different color.

I have tried:

dataset.groupby(['Date',"Product"])["Product Code"].count().plot(lw=3,color="Main app code")

generating the error, that it is an invalid RGBA argument.

If I just try:

dataset.groupby(['Date',"Product"])["Product Code"].count().plot(lw=3)

The plot does plot only the dates, where information is available.

1 Answer 1

1

How about using:

dataset.groupby(['Date',"Product"])["Product Code"].count().fillna(0).plot(lw=3)

fillna(0) should replace NaN with 0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.