Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:54:29+00:00 2026-06-16T04:54:29+00:00

This is more of a hack that almost works. #!/usr/bin/env python from pandas import

  • 0

This is more of a hack that almost works.

#!/usr/bin/env python

from pandas import *
import matplotlib.pyplot as plt
from numpy import zeros

# Create original dataframe
df = DataFrame(np.random.rand(5,4), index=['art','mcf','mesa','perl','gcc'],
                        columns=['pol1','pol2','pol3','pol4'])
# Estimate average
average = df.mean()
average.name = 'average'

# Append dummy row with zeros and then average
row = DataFrame([dict({p:0.0 for p in df.columns}), ])

df = df.append(row)
df = df.append(average)

print df

df.plot(kind='bar')
plt.show()

and gives:

             pol1      pol2      pol3      pol4
art      0.247309  0.139797  0.673009  0.265708
mcf      0.951582  0.319486  0.447658  0.259821
mesa     0.888686  0.177007  0.845190  0.946728
perl     0.902977  0.863369  0.194451  0.698102
gcc      0.836407  0.700306  0.739659  0.265613
0        0.000000  0.000000  0.000000  0.000000
average  0.765392  0.439993  0.579993  0.487194

andenter image description here

It gives the visual separation between benchmarks and average.
Is there a way to get rid of the 0 at the x-axis??


It turns out that DataFrame does not allow me to have muptiple dummy rows this way.
My solution was to change

row = pd.DataFrame([dict({p:0.0 for p in df.columns}), ])  

into

row = pd.Series([dict({p:0.0 for p in df.columns}), ]) 
row.name = ""

Series can be named with empty string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:54:31+00:00Added an answer on June 16, 2026 at 4:54 am

    Still pretty hacky, but it works:

    import pandas as pd
    import matplotlib.pyplot as plt
    import numpy as np
    
    # Create original dataframe
    df = pd.DataFrame(np.random.rand(5,4), index=['art','mcf','mesa','perl','gcc'],
                            columns=['pol1','pol2','pol3','pol4'])
    # Estimate average
    average = df.mean()
    average.name = 'average'
    
    # Append dummy row with zeros and then average
    row = pd.DataFrame([dict({p:0.0 for p in df.columns}), ])
    
    df = df.append(row)
    df = df.reindex(np.where(df.index, df.index, ''))
    df = df.append(average)
    print df
    
    df.plot(kind='bar')
    plt.show()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've an R script, that takes commandline arguments, where the top line is: #!/usr/bin/Rscript
I want to know this more in detail. Is it a realtime scheduler? An
To make this more clear, I'm going to put code samples: $file = fopen('filename.ext',
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
I am wondering if there is a way to handle this more elegantly. After
Ok, I'm going to try to make this more clear because my last question
I have a label on my asp.net page, it looks like this: more info
This is more of a design question. I have a template class, and I
This is more for information then a problem. (On searching Stack Overflow I found
This is more of an assignment work. I'm trying to help a friend debugging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.