245 """Get table (or specified columns) as a pandas DataFrame
247 To get specific columns in specified sub-levels:
249 parq = MultilevelParquetTable(filename)
250 columnDict = {'dataset':'meas',
252 'column':['coord_ra', 'coord_dec']}
253 df = parq.toDataFrame(columns=columnDict)
255 Or, to get an entire subtable, leave out one level name:
257 parq = MultilevelParquetTable(filename)
258 columnDict = {'dataset':'meas',
260 df = parq.toDataFrame(columns=columnDict)
264 columns : list or dict, optional
265 Desired columns. If `None`, then all columns will be
266 returned. If a list, then the names of the columns must
267 be *exactly* as stored by pyarrow; that is, stringified tuples.
268 If a dictionary, then the entries of the dictionary must
269 correspond to the level names of the column multi-index
270 (that is, the `columnLevels` attribute). Not every level
271 must be passed; if any level is left out, then all entries
272 in that level will be implicitly included.
274 If True drop levels of column index that have just one entry
281 return self.
_pf.read().to_pandas()
283 if isinstance(columns, dict):
288 df = self.
_df[columns]
289 except (AttributeError, KeyError):
290 newColumns = [c
for c
in columns
if c
in self.
columnIndex]
292 raise ValueError(
"None of the requested columns ({}) are available!".format(columns))
293 df = self.
_df[newColumns]
297 df = self.
_pf.read(columns=pfColumns, use_pandas_metadata=
True).to_pandas()
298 except (AttributeError, KeyError):
299 newColumns = [c
for c
in columns
if c
in self.
columnIndex]
301 raise ValueError(
"None of the requested columns ({}) are available!".format(columns))
303 df = self.
_pf.read(columns=pfColumns, use_pandas_metadata=
True).to_pandas()
307 levelsToDrop = [n
for lev, n
in zip(df.columns.levels, df.columns.names)
if len(lev) == 1]
310 if len(levelsToDrop) == len(df.columns.names):
311 levelsToDrop.remove(df.columns.names[-1])
313 df.columns = df.columns.droplevel(levelsToDrop)