I have a script that queries data from a database. It then exports it to a CSV file. The goal is to create a plot with the numeric data in the column. But the script does not see any numerical values in the column specified.
import pandas.io.data
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame
import datetime
import pandas.io.data
import psycopg2
import csv
import pandas.io.data
conn = psycopg2.connect("host='172.31.98.161' dbname='servers' user='seeker'")
cur = conn.cursor() #Create the cursor
cur.execute("select hostname, used_ram_raw from server_perf where hostname='localhost.localdomain'")
rows = cur.fetchall()
conn.close()
df = pd.DataFrame(rows, columns=['One','Two'])
df.to_csv("file.csv")
df = df.convert_objects(convert_numeric=True)
df[['Two']].plot()
plt.show()
The above script produces the following file called "file.csv"
,One,Two
0,localhost.localdomain,1521819648.00
1,localhost.localdomain,1632538624.00
2,localhost.localdomain,1633038336.00
3,localhost.localdomain,1632264192.00
The error produced is whn trying to plot is:
TypeError: Empty 'DataFrame': no numeric data to plot
Just for testing I did a
print df[['Two']]
and it printed the following
Two
0 1521819648.00
1 1632538624.00
2 1633038336.00
3 1632264192.00
What am I doing wrong? :(