当前位置: 首页>>代码示例>>Python>>正文


Python Timeseries.from_data_table方法代码示例

本文整理汇总了Python中orangecontrib.timeseries.Timeseries.from_data_table方法的典型用法代码示例。如果您正苦于以下问题:Python Timeseries.from_data_table方法的具体用法?Python Timeseries.from_data_table怎么用?Python Timeseries.from_data_table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在orangecontrib.timeseries.Timeseries的用法示例。


在下文中一共展示了Timeseries.from_data_table方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def set_data(self, data):
        # TODO: set xAxis resolution and tooltip time contents depending on
        # data.time_delta. See: http://imgur.com/yrnlgQz

        # If the same data is updated, short circuit to just updating the chart,
        # retaining all panels and list view selections ...
        if data is not None and self.data is not None and data.domain == self.data.domain:
            self.data = Timeseries.from_data_table(data)
            for config in self.configs:
                config.selection_changed()
            return

        self.data = data = None if data is None else Timeseries.from_data_table(data)
        if data is None:
            self.varmodel.clear()
            self.chart.clear()
            return
        if getattr(data.time_variable, 'utc_offset', False):
            offset_minutes = data.time_variable.utc_offset.total_seconds() / 60
            self.chart.evalJS('Highcharts.setOptions({global: {timezoneOffset: %d}});' % -offset_minutes)  # Why is this negative? It works.
            self.chart.chart()

        self.chart.setXAxisType(
            'datetime'
            if (data.time_variable and
                (getattr(data.time_variable, 'have_date', False) or
                 getattr(data.time_variable, 'have_time', False))) else
            'linear')

        self.varmodel.wrap([var for var in data.domain.variables
                            if var.is_continuous and var != data.time_variable])
开发者ID:biolab,项目名称:orange3-timeseries,代码行数:33,代码来源:owlinechart.py

示例2: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def set_data(self, data):
        self.data = data = None if data is None else Timeseries.from_data_table(data)

        def init_combos():
            for combo in (self.combo_ax1, self.combo_ax2):
                combo.clear()
            self.attrlist_model[:] = []
            for i in Spiralogram.AxesCategories:
                for combo in (self.combo_ax1, self.combo_ax2):
                    combo.addItem(_enum_str(i))
            for var in data.domain if data is not None else []:
                if (var.is_primitive() and
                        (var is not data.time_variable or
                         isinstance(var, TimeVariable) and data.time_delta is None)):
                    self.attrlist_model.append(var)
                if var.is_discrete:
                    for combo in (self.combo_ax1, self.combo_ax2):
                        combo.addItem(gui.attributeIconDict[var], var.name)

        init_combos()
        self.chart.clear()

        if data is None:
            self.commit()
            return
        self.ax1 = 'months of year'
        self.ax2 = 'years'
        self.replot()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:30,代码来源:owspiralogram.py

示例3: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def set_data(self, data):
        slider = self.slider
        self.data = data = None if data is None else Timeseries.from_data_table(data)

        def disabled():
            slider.setFormatter(str)
            slider.setHistogram(None)
            slider.setScale(0, 0)
            slider.setValues(0, 0)
            slider.setDisabled(True)
            self.send('Subset', None)

        if data is None:
            disabled()
            return

        if not isinstance(data.time_variable, TimeVariable):
            self.Error.no_time_variable()
            disabled()
            return
        self.Error.clear()
        var = data.time_variable

        time_values = np.ravel(data[:, var])
        # Save values for handler
        slider.time_values = time_values

        slider.setDisabled(False)
        slider.setHistogram(time_values)
        slider.setFormatter(var.repr_val)
        slider.setScale(time_values.min(), time_values.max())
        self.valuesChanged(slider.minimumValue(), slider.maximumValue())
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:34,代码来源:owtimeslice.py

示例4: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
 def set_data(self, data):
     self.data = data = None if data is None else Timeseries.from_data_table(data)
     self.add_button.setDisabled(not len(getattr(data, 'domain', ())))
     self.table_model.clear()
     if data is not None:
         self.var_model.wrap([var for var in data.domain
                              if var.is_continuous and var is not data.time_variable])
     self.on_changed()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:10,代码来源:owmovingtransform.py

示例5: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
 def set_data(self, data):
     self.data = data = None if data is None else Timeseries.from_data_table(data)
     self.all_attrs = []
     if data is None:
         self.plot.clear()
         return
     self.all_attrs = [(var.name, gui.attributeIconDict[var])
                       for var in data.domain
                       if (var is not data.time_variable and
                           isinstance(var, ContinuousVariable))]
     self.attrs = [0]
     self.on_changed()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:14,代码来源:owcorrelogram.py

示例6: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def set_data(self, data):
        self.data = data = None if data is None else Timeseries.from_data_table(data)

        def init_combos():
            for model in (self.combo_ax1_model, self.combo_ax2_model):
                model.clear()
            newmodel = []
            if data is not None and data.time_variable is not None:
                for model in (self.combo_ax1_model, self.combo_ax2_model):
                    model[:] = [_enum_str(i) for i in Spiralogram.AxesCategories]
            for var in data.domain.variables if data is not None else []:
                if (var.is_primitive() and
                        (var is not data.time_variable or
                         isinstance(var, TimeVariable) and data.time_delta is None)):
                    newmodel.append(var)
                if var.is_discrete:
                    for model in (self.combo_ax1_model, self.combo_ax2_model):
                        model.append(var)
            self.attrlist_model.wrap(newmodel)

        init_combos()
        self.chart.clear()

        if data is None:
            self.commit()
            return

        self.closeContext()
        self.ax2 = next((self.combo_ax2.itemText(i)
                         for i in range(self.combo_ax2.count())), '')
        self.ax1 = next((self.combo_ax1.itemText(i)
                         for i in range(1, self.combo_ax1.count())), self.ax2)
        self.agg_attr = [data.domain.variables[0]] if len(data.domain.variables) else []
        self.agg_func = 0
        if getattr(data, 'time_variable', None) is not None:
            self.openContext(data.domain)

        if self.agg_attr:
            self.attrlist.blockSignals(True)
            self.attrlist.selectionModel().clear()
            for attr in self.agg_attr:
                try:
                    row = self.attrlist_model.indexOf(attr)
                except ValueError:
                    continue
                self.attrlist.selectionModel().select(
                    self.attrlist_model.index(row),
                    QItemSelectionModel.SelectCurrent)
            self.attrlist.blockSignals(False)

        self.replot()
开发者ID:biolab,项目名称:orange3-timeseries,代码行数:53,代码来源:owspiralogram.py

示例7: commit

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def commit(self):
        data = self.data
        if not data:
            self.Outputs.time_series.send(None)
            return

        # Group-by expects data sorted
        sorted_indices = np.argsort(data.time_values)
        if not np.all(sorted_indices == np.arange(len(data))):
            data = Timeseries.from_data_table(Table.from_table_rows(data, sorted_indices))

        attrs, cvars, metas = [], [], []
        for attr, _ in self.model:
            if attr in data.domain.attributes:
                attrs.append(attr)
            elif attr in data.domain.class_vars:
                cvars.append(attr)
            else:
                metas.append(attr)

        aggreagate_time = self.AGG_TIME[self.agg_interval]

        def time_key(i):
            return timestamp(aggreagate_time(fromtimestamp(data.time_values[i])))

        times = []
        X, Y, M = [], [], []
        for key_time, indices in groupby(np.arange(len(data)), key=time_key):
            times.append(key_time)
            subset = data[list(indices)]

            xs, ys, ms = [], [], []
            for attr, func in self.model:
                values = Table.from_table(Domain([], [], [attr], source=data.domain), subset).metas
                out = (xs if attr in data.domain.attributes else
                       ys if attr in data.domain.class_vars else
                       ms)
                out.append(func(values))

            X.append(xs)
            Y.append(ys)
            M.append(ms)

        ts = Timeseries(
            Domain([data.time_variable] + attrs, cvars, metas),
            np.column_stack((times, np.row_stack(X))),
            np.array(Y),
            np.array(np.row_stack(M), dtype=object))
        self.Outputs.time_series.send(ts)
开发者ID:biolab,项目名称:orange3-timeseries,代码行数:51,代码来源:owaggregate.py

示例8: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
 def set_data(self, data):
     self.Error.clear()
     data = None if data is None else Timeseries.from_data_table(data)
     if data is not None and not isinstance(data.time_variable, TimeVariable):
         self.Error.no_time_variable()
         data = None
     self.data = data
     if data is None:
         self.model.clear()
         self.commit()
         return
     self.model.wrap([[attr,
                       AGG_FUNCTIONS[0] if attr.is_continuous else
                       Mode if attr.is_discrete else
                       Concatenate if attr.is_string else None]
                      for attr in chain(data.domain, data.domain.metas)
                      if attr != data.time_variable])
     self.commit()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:20,代码来源:owaggregate.py

示例9: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def set_data(self, data):
        if data is None or not len(data):
            self.clear()
            return
        data = Timeseries.from_data_table(data)
        if not data.time_variable:
            self.clear()
            return
        time_values = np.sort(data.time_values)

        date_to = date_from = QDateTime.fromMSecsSinceEpoch(1000 * time_values[-1]).toUTC().date()
        if len(time_values) > 1:
            date_from = QDateTime.fromMSecsSinceEpoch(1000 * time_values[0]).toUTC().date()
        self.calendar.setDateRange(date_from, date_to)
        self.calendar.update()

        self.analog_clock.setTimeSpan(time_values)
        self.digital_clock.setTime(time_values[-1])

        self.calendar.setDisabled(False)
        self.digital_clock.setDisabled(False)
开发者ID:pavlin-policar,项目名称:orange3-prototypes,代码行数:23,代码来源:owclock.py

示例10: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
    def set_data(self, data):
        slider = self.slider
        self.data = data = None if data is None else Timeseries.from_data_table(data)

        def disabled():
            slider.setFormatter(str)
            slider.setHistogram(None)
            slider.setScale(0, 0)
            slider.setValues(0, 0)
            self._set_disabled(True)
            self.Outputs.subset.send(None)

        if data is None:
            disabled()
            return

        if not isinstance(data.time_variable, TimeVariable):
            self.Error.no_time_variable()
            disabled()
            return
        self.Error.clear()
        var = data.time_variable

        time_values = data.time_values

        self._set_disabled(False)
        slider.setHistogram(time_values)
        slider.setFormatter(var.repr_val)
        slider.setScale(time_values.min(), time_values.max())
        self.valuesChanged(slider.minimumValue(), slider.maximumValue())

        # Update datetime edit fields
        min_dt = QDateTime.fromMSecsSinceEpoch(time_values[0] * 1000).toUTC()
        max_dt = QDateTime.fromMSecsSinceEpoch(time_values[-1] * 1000).toUTC()
        self.date_from.setDateTimeRange(min_dt, max_dt)
        self.date_to.setDateTimeRange(min_dt, max_dt)
        date_format = '   '.join((self.DATE_FORMATS[0] if var.have_date else '',
                                  self.DATE_FORMATS[1] if var.have_time else '')).strip()
        self.date_from.setDisplayFormat(date_format)
        self.date_to.setDisplayFormat(date_format)
开发者ID:biolab,项目名称:orange3-timeseries,代码行数:42,代码来源:owtimeslice.py

示例11: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
 def set_data(self, data):
     self.data = None if data is None else Timeseries.from_data_table(data)
     self.on_changed()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:5,代码来源:owinterpolate.py

示例12: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
 def set_data(self, data):
     self.data = data = None if data is None else Timeseries.from_data_table(data)
     self.update_model()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:5,代码来源:_owmodel.py

示例13: set_data

# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_data_table [as 别名]
 def set_data(self, data):
     self.data = data = None if data is None else Timeseries.from_data_table(data)
     if data is not None:
         self.model.wrap([var for var in data.domain
                          if var.is_continuous and var is not data.time_variable])
     self.on_changed()
开发者ID:ajdapretnar,项目名称:orange3-timeseries,代码行数:8,代码来源:owseasonaladjustment.py


注:本文中的orangecontrib.timeseries.Timeseries.from_data_table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。