如何读取布鲁内尔可视化中的日期/时间字段

时间:2016-09-01 04:48:13

标签: date time field visualization

我正在导入以下csv文件:

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)

以下表格:

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         | ...   

然后我尝试绘制线条图并获得以下错误消息:

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

并收到以下错误消息:

--------------------------------------------------------------------------- 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

我不确定,但问题是日期/时间格式。有谁知道如何阅读日期/时间字段?

1 个答案:

答案 0 :(得分:0)

尝试使用:

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

也就是说,在字段名称中使用下划线“_”而不是短划线“ - ”。布鲁内尔将干扰语法的字段名称中的字符转换为下划线,以便在语法中引用 - 但原始字段名称将在显示的轴上显示为原样。