def _read_dictionary(self, qtype = QDICTIONARY, options = READER_CONFIGURATION): if options.pandas: keys = self._read_object(options = options) values = self._read_object(options = options) if isinstance(keys, pandas.DataFrame): if not isinstance(values, pandas.DataFrame): raise QReaderException('Keyed table creation: values are expected to be of type pandas.DataFrame. Actual: %s' % type(values)) indices = keys.columns table = keys table.meta = keys.meta table.meta.qtype = QKEYED_TABLE for column in values.columns: table[column] = values[column] table.meta[column] = values.meta[column] table.set_index([column for column in indices], inplace = True) return table else: keys = keys if not isinstance(keys, pandas.Series) else keys.as_matrix() values = values if not isinstance(values, pandas.Series) else values.as_matrix() return QDictionary(keys, values) else: return QReader._read_dictionary(self, qtype = qtype, options = options)
def _read_dictionary(self, qtype=QDICTIONARY, options=READER_CONFIGURATION): if options.pandas: keys = self._read_object(options=options) values = self._read_object(options=options) if isinstance(keys, pandas.DataFrame): if not isinstance(values, pandas.DataFrame): raise QReaderException( 'Keyed table creation: values are expected to be of type pandas.DataFrame. Actual: %s' % type(values)) indices = keys.columns table = keys table.meta = keys.meta table.meta.qtype = QKEYED_TABLE for column in values.columns: table[column] = values[column] table.meta[column] = values.meta[column] table.set_index([column for column in indices], inplace=True) return table else: keys = keys if not isinstance( keys, pandas.Series) else keys.as_matrix() values = values if not isinstance( values, pandas.Series) else values.as_matrix() return QDictionary(keys, values) else: return QReader._read_dictionary(self, qtype=qtype, options=options)
def _read_dictionary(self, qtype=QDICTIONARY): if self._options.pandas: keys = self._read_object() values = self._read_object() if isinstance(keys, pandas.DataFrame): if not isinstance(values, pandas.DataFrame): raise QReaderException( 'Keyed table creation: values are expected to be of type pandas.DataFrame. Actual: %s' % type(values)) indices = keys.columns table = keys # meta attribute is obsolete, use attrs['meta'] instead if hasattr(keys, 'meta'): table.attrs['meta'] = keys.meta warnings.warn( "Usage of meta attribute is deprecated, please use attrs['meta'] instead", DeprecationWarning) else: table.attrs['meta'] = keys.attrs['meta'] table.attrs['meta'].qtype = QKEYED_TABLE if hasattr(values, 'meta'): warnings.warn( "Usage of meta attribute is deprecated, please use attrs['meta'] instead", DeprecationWarning) for column in values.columns: table[column] = values[column] table.attrs['meta'][column] = values.meta[column] else: for column in values.columns: table[column] = values[column] table.attrs['meta'][column] = values.attrs['meta'][ column] table.set_index([column for column in indices], inplace=True) return table else: keys = keys if not isinstance(keys, pandas.Series) else keys.values values = values if not isinstance( values, pandas.Series) else values.values return QDictionary(keys, values) else: return QReader._read_dictionary(self, qtype=qtype)