ten.MetaData()
Return a MetaData
object.
Syntax
ten.MetaData()
Methods
MetaData.from_path(table,ops=None)
- Creates a
MetaData
object.Arguments:
table
- A utf-8 string representing the base path.
ops
- A list representing the set of ops. The default value is None.
MetaData.from_arrays(arrays,names=None,labels=None)
- Creates a
MetaData
object.Arguments:
arrays
- A list of NumPy arrays, each with a dtype.
names
- A list of unicode column names. The default value is None,
which will generate the column names
c1
,c2
, …, etc. labels
- A list of unicode column labels. The default value is None,
which will copy
names
tolabels
.
MetaData.from_pandas(df,multiindex_ignore)
- Creates a
MetaData
object.Arguments:
df
- A pandas
DataFrame
. multiindex_ignore
- A boolean value. The default value is False, or throw an
error if a multi-indexed pandas
DataFrame
is passed. If True, the method will not throw an error if a multi-indexDataFrame
is passed.
Returns
A MetaData
object, which contains the variables
names
, labels
, and types
.
Example
In the following example, we instantiate metadata md
with
ten.GetData()
and use md.from_path()
to set
the metadata to the current state of the query. We then update the labels metadata
by replacing GM with 'General Motors' and adding ($M) to the labels.
<base table="demos.autosales"/> <code language_="python"> <![CDATA[ md = ten.MetaData() md.from_path(table) dat = ten.GetData(ops,table).as_pandas() md.labels[1] = 'General Motors' # was GM md.labels = list(map(lambda x: x +' ($M)',md.labels)) ops = ten.rebase(dat,md) ]]> </code>
The original demos.autosales
table looks like the following:
The Python code changes the labels to look like the following: