예제 #1
0
def get_target_workbook_df(conn_target, workbook_names=None):
    """
    Query details for all workbooks on the source site, or only the workbooks listed in 'workbook_names'.
    :param class conn_target: the Tableau Server connection object
    :param list workbook_names: a list of the desired workbook names whose details will be queried
    :return: Pandas DataFrame
    """
    try:
        workbook_df = get_workbooks_dataframe(conn_target)
        workbook_df.fillna(value='', inplace=True)
        if workbook_names:
            workbook_df = workbook_df[workbook_df['name'].isin(workbook_names)]
        workbook_df = flatten_dict_column(workbook_df,
                                          keys=['id', 'name'],
                                          col_name='project')
        workbook_df = flatten_dict_column(workbook_df,
                                          keys=['id', 'name', 'email'],
                                          col_name='owner')
        workbook_df.columns = [
            "target_" + column for column in workbook_df.columns
        ]
        workbook_df['target_project_name_lower'] = workbook_df[
            'target_project_name'].apply(lambda x: str(x).lower())
    except KeyError:
        workbook_df = pd.DataFrame()
    return workbook_df
예제 #2
0
def get_subscriptions_dataframe(conn):
    subscriptions_df = pd.DataFrame(get_all_subscription_fields(conn))
    subscriptions_df = flatten_dict_column(subscriptions_df,
                                           keys=['id', 'type'],
                                           col_name='content')
    subscriptions_df = flatten_dict_column(subscriptions_df,
                                           keys=['id', 'name'],
                                           col_name='schedule')
    subscriptions_df = flatten_dict_column(subscriptions_df,
                                           keys=['id', 'name'],
                                           col_name='user')
    return subscriptions_df
예제 #3
0
def get_source_datasource_df(conn_source, datasource_ids):
    datasource_df = get_datasources_dataframe(conn_source)
    if datasource_ids:
        datasource_df = datasource_df.loc[datasource_df['id'].isin(
            datasource_ids)]
    datasource_df = flatten_dict_column(datasource_df,
                                        keys=['id', 'name'],
                                        col_name='project')
    datasource_df = flatten_dict_column(datasource_df,
                                        keys=['id', 'name'],
                                        col_name='owner')
    datasource_df.columns = [
        "source_" + column for column in datasource_df.columns
    ]
    datasource_df['source_project_name_lower'] = datasource_df[
        'source_project_name'].apply(lambda x: x.lower())
    return datasource_df
예제 #4
0
def get_views_dataframe(conn, site_id=None):
    if not site_id:
        site_id = conn.site_id
    views_df = pd.DataFrame(get_all_view_fields(conn, site_id))
    views_df = flatten_dict_column(views_df,
                                   keys=['totalViewCount'],
                                   col_name='usage')
    return views_df
예제 #5
0
def get_views_dataframe(conn: TableauServerConnection,
                        site_id: Optional[str] = None) -> pd.DataFrame:
    """Returns a DataFrame describing all available views. If none are available, an empty DataFrame is returned."""
    if not site_id:
        site_id = conn.site_id
    views_df = pd.DataFrame(get_all_view_fields(conn, site_id))
    if not views_df.empty:
        views_df = flatten_dict_column(views_df,
                                       keys=["totalViewCount"],
                                       col_name="usage")
    return views_df
예제 #6
0
def get_workbook_connections_dataframe(conn, workbook_id):
    try:
        connections_json = conn.query_workbook_connections(
            workbook_id).json()['connections']['connection']
        connections_df = pd.DataFrame(connections_json)
        connections_df = flatten_dict_column(connections_df,
                                             keys=['id', 'name'],
                                             col_name='datasource')
        return connections_df
    except KeyError:
        raise ContentNotFound('workbook', workbook_id)
예제 #7
0
def get_workbook_connections_dataframe(conn: TableauServerConnection,
                                       workbook_id: str) -> pd.DataFrame:
    """Returns a DataFrame describing the connections associated with the specified workbook."""
    try:
        connections_json = conn.query_workbook_connections(
            workbook_id).json()["connections"]["connection"]
        connections_df = pd.DataFrame(connections_json)
        connections_df = flatten_dict_column(connections_df,
                                             keys=["id", "name"],
                                             col_name="datasource")
    except KeyError:
        connections_df = pd.DataFrame()
    return connections_df