Skip to content

Instantly share code, notes, and snippets.

@naomi-henderson
Created October 2, 2019 16:00
Show Gist options
  • Save naomi-henderson/cef086a4f0e1ef80681dca095f5368fd to your computer and use it in GitHub Desktop.
Save naomi-henderson/cef086a4f0e1ef80681dca095f5368fd to your computer and use it in GitHub Desktop.
Pangeo CMIP6 Catalog Viewer
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pangeo CMIP6 Catalog Viewer"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import qgrid"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"number of zstores: 22027\n"
]
}
],
"source": [
"cat_csv = 'https://cmip6.storage.googleapis.com/cmip6.csv'\n",
"dfcat = pd.read_csv(cat_csv)\n",
"\n",
"print('number of zstores:',dfcat.shape[0])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d1c9a5ca87fe405e8615344c2258c970",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"QgridWidget(grid_options={'fullWidthRows': True, 'syncColumnCellResize': True, 'forceFitColumns': True, 'defau…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"widget=qgrid.show_grid(dfcat.drop(['activity_id','institution_id'],1))\n",
"widget"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# save results\n",
"df = widget.get_changed_df() # use this to save filtered dataframe\n",
"# df = widget.get_selected_df() # use this instead to save selected rows"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"zstores = sorted(df.zstore.values)\n",
"print(zstores[0:10])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.to_csv('save.csv', mode='w', index=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment