0

I'm importing the following csv file:

import pandas as pd
from numpy import log, abs, sign, sqrt
import brunel

# Read data
DISKAVGRIO = pd.read_csv("../DISKAVGRIO_nmon.csv")

DISKAVGRIO.head(6)

And the following table:

Hostname      | Date-Time                   | hdisk1342    | hdisk1340     | hdisk1343   | ...   
------------  | -----------------------     | -----------  | ------------- | ----------- | ------ 
host1         | 12-08-2015 00:56:12         | 0.0          | 0.0           | 0.0         | ...   
host1         | 12-08-2015 01:11:13         | 0.0          | 0.0           | 0.0         | ...   
host1         | 12-08-2015 01:26:14         | 0.0          | 0.0           | 0.0         | ...   
host1         | 12-08-2015 01:41:14         | 0.0          | 0.0           | 0.0         | ...   
host1         | 12-08-2015 01:56:14         | 0.0          | 0.4           | 4.2         | ...   
host1         | 12-08-2015 02:11:14         | 0.0          | 0.0           | 0.0         | ...   

Then I try to plot a line graphic and get the following error message:

# Line plot
%brunel data('DISKAVGRIO') x(Date-Time) y(hdisk1342) color(#series) line

And get the following error message:

--------------------------------------------------------------------------- java.lang.RuntimeExceptionPyRaisable Traceback (most recent call last) <ipython-input-4-1c7cb7700929> in <module>()
      1 # Line plot
----> 2 get_ipython().magic("brunel data('DISKAVGRIO') x(Date-Time) y(hdisk1342) color(#series) line")
/home/anobre/anaconda3/lib/python3.5/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
   2161         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2162         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2163         return self.run_line_magic(magic_name, magic_arg_s)
   2164 
   2165     #-------------------------------------------------------------------------
/home/anobre/anaconda3/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
   2082                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2083             with self.builtin_trap:
-> 2084                 result = fn(*args,**kwargs)
   2085             return result
   2086 
<decorator-gen-124> in brunel(self, line, cell)
/home/anobre/anaconda3/lib/python3.5/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):
/home/anobre/anaconda3/lib/python3.5/site-packages/brunel/magics.py in brunel(self, line, cell)
     42         parts = line.split('::')
     43         action = parts[0].strip()
---> 44         datasets_in_brunel = brunel.get_dataset_names(action)
     45         self.cache_data(datasets_in_brunel,datas)
     46         if len(parts) > 2:
/home/anobre/anaconda3/lib/python3.5/site-packages/brunel/brunel.py in get_dataset_names(brunel_src)
     92 
     93 def get_dataset_names(brunel_src):
---> 94     return brunel_util_java.D3Integration.getDatasetNames(brunel_src)
     95 
     96 def cacheData(data_key, data):
java.lang.RuntimeExceptionPyRaisable: org.brunel.model.VisException: Illegal field name: Date-Time while parsing action text: data('DISKAVGRIO') x(Date-Time) y(hdisk1342) color(#series) line

I'm not sure but I thing the problem is the date/time format. Does anyone know how to read date/time fields?

1 Answers1

0

Try using:

%brunel data('DISKAVGRIO') x(Date_Time) y(hdisk1342) color(#series) line

That is, use an underscore "_" instead of a dash "-" within the field name. Brunel converts characters in field names that interfere with the syntax into underscores for reference within the syntax--but the original field name will appear as is on the displayed axis.

Dan
  • 31
  • You will also likely need to parse the date column when loading in pandas as in: `pd.read_csv("../DISKAVGRIO_nmon.csv", parse_dates=["Date-Time"])` – Dan Sep 02 '16 at 14:35
  • Thanks for your information. I did this, but also followed the recomendation to format date/time fields from this link: http://stackoverflow.com/questions/17465045/can-pandas-automatically-recognize-dates/17468012#17468012 – Anderson Nobre Sep 05 '16 at 17:42