Python - creating a histogram based on a .csv file content

Dear Experts,

I have the following data in the table on the printscreen,
Example data
which are actually imported from a .csv file by this Python code and as you can see also started to setup a histogram chart with those plt. related lines:

import csv
import matplotlib.pyplot as plt

with open(r"C:\Demo.csv") as csvfile:
    rows = list(csv.reader(csvfile))
    data_header = rows[0]
    data_rows = rows[1:]

plt.ylabel("Points")
plt.xlabel("Weeks") 
plt.xticks(range(0,5))
plt.yticks(range(1,21))
plt.title('Demo chart')
plt.show()

Open in new window


My question would be actually, that instead of the line:

plt.xticks(range(0,5))

Open in new window


how to use the content of data_rows[0] so the header values from my table? (concretely so Week1, Week2, Week3, Week4). Would be that line something like plt.xticks(data_header[0])? (it does not work in that format)

Thanks in advance,
LVL 1
csehzIT consultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
Not exactly sure what you're looking for.

Note: the [0] in this statement is "Category", and not the list of header row strings.
plt.xticks(data_header[0])

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
csehzIT consultantAuthor Commented:
Thank you I will need to re-think it and summarize the whole concept in one EE question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.