#!/usr/bin/python
import pandas as pd
import numpy as np
import matplotlib
import datetime as dt

from matplotlib import pyplot as plt

# Import modules from /batterym/ folder.
import sys
sys.path.append('../batterym')
import log


# Emulates the aesthetics of ggplot (a popular plotting package for R).
plt.style.use('ggplot')

logs = log.get_battery('../logs/capacity_example')
data = pd.DataFrame(logs)
data = data.rename(columns={'time': 'timestamp'})
data['date'] = pd.Series(data['timestamp'].dt.date)
data['time'] = pd.Series(data['timestamp'].dt.time)
data['weekday'] = pd.Series(data['timestamp'].dt.weekday)

print data.head()

plt.figure()
data['capacity'].plot()

# plt.figure()
# data['weekday'].hist(bins=7)

# plt.figure()
# data['capacity'].hist(bins=10)

# plt.figure()
# data['time'].hist(bins=24)

plt.show()

@@ -612,16 +612,213 @@
 ekday)%0A%0A
+# Add relative time.%0Amost_recent_datetime = data%5B'timestamp'%5D.iloc%5B-1%5D%0Aprint 'Most recent time: ', most_recent_datetime%0Adata%5B'relative_time'%5D = pd.Series(most_recent_datetime - data%5B'timestamp'%5D)%0A%0A
 print da
@@ -828,16 +828,19 @@
 head()%0A%0A
+%0A# 
 plt.figu
@@ -844,16 +844,18 @@
 igure()%0A
+# 
 data%5B'ca
@@ -1012,16 +1012,18 @@
 ns=24)%0A%0A
+# 
 plt.show

add relative time