7.4.5 Get Information About Datastore Objects
The oml.ds.describe
function provides information about the objects in a datastore.
The syntax of oml.ds.describe
is the following:
oml.ds.describe(name, owner=None))
The name
argument is a string that specifies the name of a datastore.
The owner
argument is a string that specifies the owner of the datastore or None
(the default). If you do not specify the owner, then the function returns information about the datastore if it is owned by the current user.
The oml.ds.describe
function returns a pandas.DataFrame
object, each row of which represents an object in the datastore. The columns of the DataFrame
are the following:
-
object_name, which specifies the name of the object
-
class, which specifies the class of the object
-
size, which specifies the size of the object in bytes
-
length, which specifies the length of the object
-
row_count, which specifies the rows of the object
-
col_count, which specifies the columns of the object
This function raises a ValueError
if the following occur:
-
The current user is not the owner of the datastore and has not been granted read privilege for the datastore.
-
The datastore does not exist.
Example 7-17 Getting Information About Datastore Objects
This example demonstrates the using the oml.ds.describe
function. For the creation of the datastore used in this example, see Example 7-14.
import oml
# Describe the contents of the ds_pydata datastore.
oml.ds.describe(name='ds_pydata')
oml.ds.describe(name="ds_pydata")[['object_name', 'class']]
Listing for This Example
>>> import oml
>>>
>>> # Describe the contents of the ds_pydata datastore.
... oml.ds.describe(name='ds_pydata')
object_name class size length row_count col_count
0 oml_boston oml.DataFrame 1073 506 506 14
1 oml_diabetes oml.DataFrame 964 442 442 11
2 wine Bunch 24177 5 1 5
>>> oml.ds.describe(name="ds_pydata")[['object_name', 'class']]
object_name class
0 oml_boston oml.DataFrame
1 oml_diabetes oml.DataFrame
2 wine Bunch
Parent topic: Save Python Objects in the Database