{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc7810e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from scipy import stats\n",
    "import plotly.express as px\n",
    "import plotly.io as pio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4705177e",
   "metadata": {},
   "outputs": [],
   "source": [
    "diamanti = pd.read_csv(\"diamonds.csv\")\n",
    "diamanti.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b56df03f",
   "metadata": {},
   "outputs": [],
   "source": [
    "diamanti.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ab094947",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2a1ee7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d6a101a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "pio.templates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d37e939",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2, template=\"plotly_white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "737dd4a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.density_heatmap(diamanti, x=\"carat\", y=\"price\", nbinsx=30, nbinsy=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0591e66e",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", color=\"cut\", opacity=0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "859de41c",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2, facet_col=\"cut\", facet_col_wrap=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e099bb17",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2, facet_col=\"color\", facet_col_wrap=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "555064ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2, facet_col=\"color\", facet_col_wrap=3, category_orders=\n",
    "          {\"color\": list(\"DEFGHIJ\")})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "438d5997",
   "metadata": {},
   "outputs": [],
   "source": [
    "slope, intercept, *rest = stats.linregress(diamanti.carat, diamanti.price)\n",
    "x=np.arange(0,5,1)\n",
    "y=x*slope+intercept\n",
    "px.line(x=x, y=y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "655a1672",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2, trendline='ols', range_y=[0,20000])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d8e17d06",
   "metadata": {},
   "outputs": [],
   "source": [
    "px.scatter(diamanti, x=\"carat\", y=\"price\", opacity=0.2, color=\"cut\", trendline='ols', range_y=[0,20000])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0479e93a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
