user1862965
user1862965

Reputation: 386

Pandas Pivot Table Column with empty value do not show

I need your help:

I have dataframe d3:

dataframe

i am using pivot_table

df4 = df3.pivot_table(index = ['Number','Department','Task'], columns="Date", values="Score",fill_value = 'N/A')

output d4 looks like:

enter image description here

why is not showing rows where Task empty is. What i am doing wrong?

I would like to create dataframe like this:

enter image description here

Upvotes: 3

Views: 7429

Answers (1)

jezrael
jezrael

Reputation: 862741

I think here is necessary replace misisng values before pivot_table:

cols = ['Number','Department','Task']
df[cols] = df[cols].fillna('N/A')

Upvotes: 5

Related Questions