Python Forum

Full Version: blank graph with matplotlib from a csv file / data type issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All. I'm new to Python and hoping to get some help here. I'm trying to create some simple bar/line graphs from a csv file, however, it gives me an empty graph until I open this csv file manually in excel and change the data type to numeric. I've tried changing the data type with pd.to_numeric but it still gives an empty graph.

The csv that I'm trying to visualise is web data that I scraped using Beautiful Soup, I used .text method do get rid of all of the HTML tags so maybe it's causing the issue?

Would really appreciate some help. thanks!

Data file: https://dropmefiles.com/AYTUT

import numpy
import matplotlib
from matplotlib import pyplot as plt
import pandas as pd
import csv

my_data = pd.read_csv('my_data.csv')
plt.bar(x= my_data['Company'], height= my_data['Market_Cap'])
plt.show()