I have a csv file with 25 columns and 90 rows. The first column is in date format such that it appears as 01-10-2014 for example. The rest of the columns contain numbers that correspond to those dates. The first row is the name for each column. My plan was to write a code that took in all the information and gave me the flexibility to plot any two columns against each other as a scatter xy plot. I have copied my code so far below.
The code works fine if I remove 'weekly' and 'f8' from the dtype. It plots the date in the X-axis and the first column 'daily' in the Y-axis. I assumed I could then just add additional columns like I did with the 'weekly' as shown below. However, I get the error:
Traceback (most recent call last):
File "plot_dataset_second.py", line 10, in <module>
Date = [DT.datetime.strptime(key,"%d-%m-%Y") for (key, value) in data]
ValueError: too many values to unpack
Sample data:
Date Daily Installs Weekly Installs Mean Install Duration
01-10-14 153 153 47.71
02-10-14 630 783 51.9
03-10-14 50 833 49.94
04-10-14 973 1805 51.43
import numpy as np
import matplotlib.pyplot as plt
import datetime as DT
data= np.genfromtxt('dataset1_changed.csv', delimiter=',',
dtype={'names': ('Date', 'daily', 'weekly'),'formats': ('S10', 'f8', 'f8')} )
Date = [DT.datetime.strptime(key,"%d-%m-%Y") for (key, value) in data]
daily = [value for (key, value) in data]
weekly = [value for (key, value) in data]
#y = [value for (key, value) in data]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.grid()
fig.autofmt_xdate()
plt.plot(Date,daily,'b--o--')
plt.xlabel('Date')
plt.ylabel('Daily Count')
plt.title('Daily Count since February')
plt.show()