How to access table meta data
This guide will show you how to access the meta data for your table.
The meta_table
attribute creates a new table that contains the table's meta data. Specifically, this table contains information about every column in the original table.
result = source.meta_table
This can be useful when you want to confirm which columns in a table are partitioning or grouping, or verify the data type of a column.
Let's create a table of weather data for Miami, Florida.
from deephaven import new_table
from deephaven.column import string_col, int_col, double_col
miami = new_table([
string_col("Month", ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]),
int_col("Temp", [60, 62, 65, 68, 73, 76, 77, 77, 76, 74, 68, 63]),
double_col("Rain", [1.62, 2.25, 3.00, 3.14, 5.34, 9.67, 6.50, 8.88, 9.86, 6.33, 3.27, 2.04])
])
- miami
We can access the meta data as follows:
meta = miami.meta_table
- meta
Obviously, this is more useful for a table we are unfamiliar with, but as you can see, the meta
table provides information about the column and data types.
Now, let's create a table of weather data for Miama over three dates in January, then averages the high and low temperatures by day.
from deephaven import new_table
from deephaven.column import string_col, int_col
miami = new_table([
string_col("Day", ["Jan 1", "Jan 1", "Jan 2", "Jan 2", "Jan 3", "Jan 3"]),
int_col("Temp", [45, 62, 48, 63, 39, 59]),
])
avg_temp = miami.avg_by(by=["Day"])
- miami
- avg_temp
Although the Temp
column is originally created as an int column, the Temp
column in the avg_by
table becomes a double column. We can see this by hovering over the column header in the UI, and also by accessing the table's metadata.
meta = avg_temp.meta_table
- meta