# Loading a saved table to pandas dataframe

**URL:** https://community.wandb.ai/t/loading-a-saved-table-to-pandas-dataframe/2063
**Category:** W&B Help
**Tags:** artifacts, projects, tables, wandb
**Created:** [March 11, 2022, 10:29pm UTC](https://community.wandb.ai/t/loading-a-saved-table-to-pandas-dataframe/2063 "2022-03-11T22:29:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![prateeky2806](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@prateeky2806](https://community.wandb.ai/u/prateeky2806)
#### Post date: [March 11, 2022, 10:29pm UTC](https://community.wandb.ai/t/loading-a-saved-table-to-pandas-dataframe/2063/1 "2022-03-11T22:29:56Z")

</div>

Hi, I have been recently using wandb a lot in my projects and it is really helpful.

my issue is that I an trying access the logged tables as a pandas dataframe in a program. I check the documentation and tried the solution mentioned in the [documentation here](https://docs.wandb.ai/guides/data-vis/log-tables#access-tables-programmatically). Once I run this instead of getting the table it returns a dictionary like this

```auto
{'artifact_path': 'wandb-client-artifact://sx4urflmwtczzq7zf71hsfxkill8hqrnd8o4uirjbcswuuc29f0xxrq6nra7uo2kzsp8jmu4s2g53e7xl3xuyu4lfjiowz9v63r9fbn7d3r8ckmlz5lrkhncuyhr0e46:latest/metrics.table.json', '_latest_artifact_path': 'wandb-client-artifact://sx4urflmwtczzq7zf71hsfxkill8hqrnd8o4uirjbcswuuc29f0xxrq6nra7uo2kzsp8jmu4s2g53e7xl3xuyu4lfjiowz9v63r9fbn7d3r8ckmlz5lrkhncuyhr0e46:latest/metrics.table.json', 'path': 'media/table/metrics_2_491a3e34c6fcf4271cb2.table.json', 'size': 413, '_type': 'table-file', 'ncols': 9, 'nrows': 3, 'sha256': '491a3e34c6fcf4271cb2378f9a33ff5dc8c9cdb8268299b4f96b88151730ecad'}

```

It would be great if someone can help me to convert this to a table so that I can perform aggregations on the results.

Thanks  
Prateek

---

<div class="post-metadata">

### Author: ![dschaub](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@dschaub](https://community.wandb.ai/u/dschaub)
#### Post date: [March 13, 2022, 3:00pm UTC](https://community.wandb.ai/t/loading-a-saved-table-to-pandas-dataframe/2063/2 "2022-03-13T15:00:33Z")

</div>

Hey Prateek,

you can use this function (its a modified version of a function from the wandb repo).

```auto
def get_table_data_from_url(source_url: str, api_key: Optional[str] = None) -> None:
    response = requests.get(source_url, auth=("api", api_key), stream=True, timeout=5)
    response.raise_for_status()
    bytes_list = []
    for data in response.iter_content(chunk_size=1024):
        bytes_list.append(data)
    final_byte_data = b"".join(bytes_list)
    data_dict = json.loads(final_byte_data.decode("utf-8"))
    table_df = pd.DataFrame(data=data_dict["data"], columns=data_dict["columns"])
    return table_df

```

To get the specific url of the artifact, you can just iterate over run.files() and save the url attribute of the returned files. By checking out the file names you should be able to see which files are relevant for you.

Best  
Darius

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)
#### Post date: [May 12, 2022, 3:01pm UTC](https://community.wandb.ai/t/loading-a-saved-table-to-pandas-dataframe/2063/3 "2022-05-12T15:01:00Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
