Files
fenago f3b24b4b7f added
2021-02-07 15:16:01 +05:00

155 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "HEiOAwQPW0qb"
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "j7whidfaYjns"
},
"outputs": [],
"source": [
"file_url = '../dataset/ames_iowa_housing.csv'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "nFMz2jNVt-xy"
},
"outputs": [],
"source": [
"df = pd.read_csv(file_url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "D74unKky461E"
},
"outputs": [],
"source": [
"num_df = df.select_dtypes(include='number')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 170
},
"colab_type": "code",
"id": "bYS2m8qK6hqr",
"outputId": "5843a3b5-a2cf-4eac-c3bb-c589b2d38ea2"
},
"outputs": [],
"source": [
"num_cols = num_df.columns\n",
"num_cols"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "6VX9ZfOPb81u"
},
"outputs": [],
"source": [
"def describe_numeric(df, col_name):\n",
" print(f\"\\nCOLUMN: {col_name}\")\n",
" print(f\"Minimum: {df[col_name].min()}\")\n",
" print(f\"Maximum: {df[col_name].max()}\")\n",
" print(f\"Average: {df[col_name].mean()}\")\n",
" print(f\"Standard Deviation: {df[col_name].std()}\")\n",
" print(f\"Median: {df[col_name].median()}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 136
},
"colab_type": "code",
"id": "xwaJOSQBfWIK",
"outputId": "d82fa754-f2d2-43c0-a4ec-788e25f37bd9"
},
"outputs": [],
"source": [
"describe_numeric(df, 'SalePrice')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"colab_type": "code",
"id": "aM3eEOmJfkRk",
"outputId": "b3cb94de-20e1-4ad9-cf6e-7951d2c1c5bf"
},
"outputs": [],
"source": [
"for col_name in num_cols:\n",
" describe_numeric(df, col_name)"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "Exercise10_03.ipynb",
"provenance": []
},
"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.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}