Last active
July 31, 2024 22:09
-
-
Save sualeh/8b5783b84f41076f9824538dc3337835 to your computer and use it in GitHub Desktop.
create_and_download_spreadsheet.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"private_outputs": true, | |
"provenance": [], | |
"authorship_tag": "ABX9TyMThmCo5AdiVJneZaeEAqdm", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/sualeh/8b5783b84f41076f9824538dc3337835/untitled2.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "kZvbKANS1Um0" | |
}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"from google.colab import files\n", | |
"\n", | |
"# Create data set\n", | |
"data = [('Tom', 10), ('Nick', 15), ('Julie', 14)]\n", | |
"df = pd.DataFrame(data, columns=['Name', 'Age'])\n", | |
"\n", | |
"# DEBUG - print dataframe\n", | |
"print(df)\n", | |
"\n", | |
"# Create Excel file from data set\n", | |
"with pd.ExcelWriter('ages.xlsx') as writer:\n", | |
" df.to_excel(writer, sheet_name=\"Kid's Ages\")\n", | |
"\n", | |
"# Download the file\n", | |
"files.download('ages.xlsx')\n" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment