1795 lines
61 KiB
Text
1795 lines
61 KiB
Text
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "937a6197-91e0-48f6-ba48-2aba923698a6",
|
||
"metadata": {},
|
||
"source": [
|
||
"# PythonAI"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"id": "e1b6fa60-9b9e-4647-ab72-29b3eb0a92d2",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import numpy as np\n",
|
||
"import pandas as pd"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"id": "44c4e5ed-7975-49f9-b487-4fba07e0b300",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"data = np.genfromtxt(\"/home/sasza/Pobrane/AAPL_stock_price_example.csv\", delimiter=',', usecols=(1), names=True)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"id": "3dc69a27-1354-4381-9cec-673a46d7d8ac",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array([[90, 85, 88],\n",
|
||
" [72, 78, 80],\n",
|
||
" [95, 92, 93]])"
|
||
]
|
||
},
|
||
"execution_count": 6,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"# uczniowie, wyniki testu\n",
|
||
"oceny = np.array([\n",
|
||
" [90,85,88],\n",
|
||
" [72,78,80],\n",
|
||
" [95,92,93]\n",
|
||
"])\n",
|
||
"oceny"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "61187ee7-a773-4fb5-b129-158061a76c81",
|
||
"metadata": {},
|
||
"source": [
|
||
"# Maski logiczne\n",
|
||
"będą powszechnie wykorzystane w Pandas"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"id": "4c7d82b9-9730-4760-97bb-f3de73570934",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"[[False False True]\n",
|
||
" [ True False True]\n",
|
||
" [ True True True]]\n",
|
||
"[ 4 6 12 123 13 3123]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"# maski logiczne\n",
|
||
"tab = np.array([\n",
|
||
" [2,3,4],\n",
|
||
" [6,2,12],\n",
|
||
" [123,13,3123]\n",
|
||
"])\n",
|
||
"\n",
|
||
"maska = tab > 3\n",
|
||
"print(maska)\n",
|
||
"print(tab[maska])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 13,
|
||
"id": "637d3ad3-9995-417a-900b-54815a18102a",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array([2, 3, 4, 2])"
|
||
]
|
||
},
|
||
"execution_count": 13,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"tab[(tab > 2) & (tab < 7)]\n",
|
||
"tab[~(tab > 4)]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 16,
|
||
"id": "56012b75-9413-462a-9244-8b3699b32d1a",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array([88, 91, 0, 75, 99, 0])"
|
||
]
|
||
},
|
||
"execution_count": 16,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"w = np.array([88,91,-1,75,99,-5])\n",
|
||
"w * (w>=0)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "e0a6bfd9-1e5a-4dc8-8f80-f73641a1b336",
|
||
"metadata": {},
|
||
"source": [
|
||
"# Pandas"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 20,
|
||
"id": "e052d5de-d25e-4cb0-a4ad-60aa1c7ba539",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"2.2.3\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"print(pd.__version__)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 48,
|
||
"id": "61c1cf75-c094-429b-8777-728a16036d68",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
" product a product b product c\n",
|
||
"Kielce 13 20 200\n",
|
||
"Łódź 20 30 10\n",
|
||
"Kraków 0 10 0\n",
|
||
"Poznań 10 1 -3\n",
|
||
"product a 20\n",
|
||
"product b 30\n",
|
||
"product c 10\n",
|
||
"Name: Łódź, dtype: int64\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"product_data = {\n",
|
||
" 'product a': [13,20,0,10],\n",
|
||
" 'product b': [20,30,10,1],\n",
|
||
" 'product c': [200,10,0,-3],\n",
|
||
"}\n",
|
||
"\n",
|
||
"dane_sprzedazowe = pd.DataFrame(product_data, index=[\"Kielce\",\"Łódź\", \"Kraków\", \"Poznań\"])\n",
|
||
"print(dane_sprzedazowe)\n",
|
||
"print(dane_sprzedazowe.loc['Łódź'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 85,
|
||
"id": "5e495c66-927f-4ee6-ae52-6e02c9ad138e",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
" Date Close\n",
|
||
"0 2019-01-02 157.919998\n",
|
||
"1 2019-01-03 142.190002\n",
|
||
"2 2019-01-04 148.259995\n",
|
||
"3 2019-01-07 147.929993\n",
|
||
"4 2019-01-08 150.750000\n",
|
||
".. ... ...\n",
|
||
"224 2019-11-20 263.190002\n",
|
||
"225 2019-11-21 262.010010\n",
|
||
"226 2019-11-22 261.779999\n",
|
||
"227 2019-11-25 266.369995\n",
|
||
"228 2019-11-26 264.290009\n",
|
||
"\n",
|
||
"[229 rows x 2 columns]\n",
|
||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||
"RangeIndex: 229 entries, 0 to 228\n",
|
||
"Data columns (total 2 columns):\n",
|
||
" # Column Non-Null Count Dtype \n",
|
||
"--- ------ -------------- ----- \n",
|
||
" 0 Date 229 non-null object \n",
|
||
" 1 Close 229 non-null float64\n",
|
||
"dtypes: float64(1), object(1)\n",
|
||
"memory usage: 3.7+ KB\n",
|
||
"None\n",
|
||
" Close\n",
|
||
"count 229.000000\n",
|
||
"mean 201.477598\n",
|
||
"std 28.246961\n",
|
||
"min 142.190002\n",
|
||
"25% 182.539993\n",
|
||
"50% 200.720001\n",
|
||
"75% 213.279999\n",
|
||
"max 267.100006\n",
|
||
"(229, 2)\n",
|
||
"Index(['Date', 'Close'], dtype='object')\n",
|
||
" Date Close\n",
|
||
"0 False False\n",
|
||
"1 False False\n",
|
||
"2 False False\n",
|
||
"3 False False\n",
|
||
"4 False False\n",
|
||
".. ... ...\n",
|
||
"224 False False\n",
|
||
"225 False False\n",
|
||
"226 False False\n",
|
||
"227 False False\n",
|
||
"228 False False\n",
|
||
"\n",
|
||
"[229 rows x 2 columns]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"data = pd.read_csv(\"data/AAPL_stock_price_example.csv\")\n",
|
||
"# data = pd.read_csv(\"./AAPL_stock_price_example.csv\", parse_dates=[\"Date\")\n",
|
||
"print(data)\n",
|
||
"print(data.info())\n",
|
||
"print(data.describe())\n",
|
||
"print(data.shape)\n",
|
||
"print(data.columns)\n",
|
||
"print(data.isnull())"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 74,
|
||
"id": "d016fb3a-efce-407c-afc2-619380fea702",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>product</th>\n",
|
||
" <th>wholesale_price</th>\n",
|
||
" <th>msrp</th>\n",
|
||
" <th>qty_ordered</th>\n",
|
||
" <th>qty_shipped</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>skippys_dream</td>\n",
|
||
" <td>8.99</td>\n",
|
||
" <td>18.38</td>\n",
|
||
" <td>100</td>\n",
|
||
" <td>100</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>just_the_beef</td>\n",
|
||
" <td>4.99</td>\n",
|
||
" <td>10.43</td>\n",
|
||
" <td>200</td>\n",
|
||
" <td>195</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>potatos_and_lamb</td>\n",
|
||
" <td>5.19</td>\n",
|
||
" <td>11.43</td>\n",
|
||
" <td>50</td>\n",
|
||
" <td>50</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>turkey_and_cranberries</td>\n",
|
||
" <td>5.98</td>\n",
|
||
" <td>12.00</td>\n",
|
||
" <td>50</td>\n",
|
||
" <td>50</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>roasted_duck</td>\n",
|
||
" <td>9.59</td>\n",
|
||
" <td>17.48</td>\n",
|
||
" <td>15</td>\n",
|
||
" <td>15</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" product wholesale_price msrp qty_ordered qty_shipped\n",
|
||
"0 skippys_dream 8.99 18.38 100 100\n",
|
||
"1 just_the_beef 4.99 10.43 200 195\n",
|
||
"2 potatos_and_lamb 5.19 11.43 50 50\n",
|
||
"3 turkey_and_cranberries 5.98 12.00 50 50\n",
|
||
"4 roasted_duck 9.59 17.48 15 15"
|
||
]
|
||
},
|
||
"execution_count": 74,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data = pd.read_excel(\"data/dog_food_orders.xlsx\")\n",
|
||
"data"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 82,
|
||
"id": "755eaff8-b0a2-4d2f-aaba-590441eaa748",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"Index(['dteday', 'hr', 'cnt'], dtype='object')"
|
||
]
|
||
},
|
||
"execution_count": 82,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"import sqlite3\n",
|
||
"con = sqlite3.connect(\"data/bike_share.db\")\n",
|
||
"data = pd.read_sql(\"SELECT * FROM rentals\", con)\n",
|
||
"data = data.set_index(\"index\")\n",
|
||
"data"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 139,
|
||
"id": "c08a3987-83b3-4314-a2a5-ed0da13d11ac",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>Name</th>\n",
|
||
" <th>Telephone</th>\n",
|
||
" <th>Email</th>\n",
|
||
" <th>Office</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Dr. Sally</td>\n",
|
||
" <td>555-1234</td>\n",
|
||
" <td>sally@calpoly.edu</td>\n",
|
||
" <td>12-34</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Dr. Steve</td>\n",
|
||
" <td>555-5678</td>\n",
|
||
" <td>steve@calpoly.edu</td>\n",
|
||
" <td>56-78</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Dr. Kathy</td>\n",
|
||
" <td>555-9012</td>\n",
|
||
" <td>kathy@calpoly.edu</td>\n",
|
||
" <td>90-123</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" Name Telephone Email Office\n",
|
||
"0 Dr. Sally 555-1234 sally@calpoly.edu 12-34\n",
|
||
"1 Dr. Steve 555-5678 steve@calpoly.edu 56-78\n",
|
||
"2 Dr. Kathy 555-9012 kathy@calpoly.edu 90-123"
|
||
]
|
||
},
|
||
"execution_count": 139,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data = pd.read_html(\"https://afd.calpoly.edu/web/sample-tables\")\n",
|
||
"data[1]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 163,
|
||
"id": "e06d2078-5eff-40c8-945e-096b1bbd73b8",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"<Response [200]>"
|
||
]
|
||
},
|
||
"execution_count": 163,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"import requests\n",
|
||
"import datetime as dt\n",
|
||
"yesterday = dt.date.today() - dt.timedelta(days=1)\n",
|
||
"api = \"https://earthquake.usgs.gov/fdsnws/event/1/query\"\n",
|
||
"payload = {\n",
|
||
" \"format\": \"geojson\",\n",
|
||
" \"starttime\": yesterday - dt.timedelta(days=7),\n",
|
||
" \"endtime\": yesterday\n",
|
||
"}\n",
|
||
"response = requests.get(api, params=payload)\n",
|
||
"response"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 194,
|
||
"id": "5ca9c016-fbb6-4b1d-a424-9a396152857b",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"json = response.json()\n",
|
||
"\n",
|
||
"data = [quake['properties'] for quake in json['features']]\n",
|
||
"data = pd.DataFrame(data)\n",
|
||
"\n",
|
||
"# data.sort_values(by='mag', ascending=False)\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 199,
|
||
"id": "53002cd9-4747-48f9-ba75-58bd367f943b",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>mag</th>\n",
|
||
" <th>place</th>\n",
|
||
" <th>time</th>\n",
|
||
" <th>updated</th>\n",
|
||
" <th>tz</th>\n",
|
||
" <th>url</th>\n",
|
||
" <th>detail</th>\n",
|
||
" <th>felt</th>\n",
|
||
" <th>cdi</th>\n",
|
||
" <th>mmi</th>\n",
|
||
" <th>...</th>\n",
|
||
" <th>ids</th>\n",
|
||
" <th>sources</th>\n",
|
||
" <th>types</th>\n",
|
||
" <th>nst</th>\n",
|
||
" <th>dmin</th>\n",
|
||
" <th>rms</th>\n",
|
||
" <th>gap</th>\n",
|
||
" <th>magType</th>\n",
|
||
" <th>type</th>\n",
|
||
" <th>title</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>1.56</td>\n",
|
||
" <td>5 km NNW of Boron, CA</td>\n",
|
||
" <td>2025-03-23 23:56:23.000</td>\n",
|
||
" <td>2025-03-24 00:01:09.995</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,ci40908351,</td>\n",
|
||
" <td>,ci,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>36.0</td>\n",
|
||
" <td>0.110000</td>\n",
|
||
" <td>0.20</td>\n",
|
||
" <td>40.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.6 - 5 km NNW of Boron, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>1.60</td>\n",
|
||
" <td>31 km NW of Toyah, Texas</td>\n",
|
||
" <td>2025-03-23 23:55:05.246</td>\n",
|
||
" <td>2025-03-24 15:17:33.050</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,tx2025ftvc,</td>\n",
|
||
" <td>,tx,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>14.0</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" <td>0.20</td>\n",
|
||
" <td>62.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.6 - 31 km NW of Toyah, Texas</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>1.70</td>\n",
|
||
" <td>6 km NNE of Windsor, CA</td>\n",
|
||
" <td>2025-03-23 23:52:39.960</td>\n",
|
||
" <td>2025-03-25 12:07:17.366</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75154137,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,focal-mechanism,nearby-cities,origin,phase-da...</td>\n",
|
||
" <td>64.0</td>\n",
|
||
" <td>0.074130</td>\n",
|
||
" <td>0.08</td>\n",
|
||
" <td>45.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.7 - 6 km NNE of Windsor, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>5.10</td>\n",
|
||
" <td>154 km ESE of Neiafu, Tonga</td>\n",
|
||
" <td>2025-03-23 23:36:24.213</td>\n",
|
||
" <td>2025-03-24 01:09:53.040</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,us7000pm4g,</td>\n",
|
||
" <td>,us,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>58.0</td>\n",
|
||
" <td>2.567000</td>\n",
|
||
" <td>0.88</td>\n",
|
||
" <td>62.0</td>\n",
|
||
" <td>mb</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 5.1 - 154 km ESE of Neiafu, Tonga</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>1.15</td>\n",
|
||
" <td>14 km ENE of Indio, CA</td>\n",
|
||
" <td>2025-03-23 23:35:52.810</td>\n",
|
||
" <td>2025-03-23 23:40:43.046</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,ci40908335,</td>\n",
|
||
" <td>,ci,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>39.0</td>\n",
|
||
" <td>0.118400</td>\n",
|
||
" <td>0.19</td>\n",
|
||
" <td>47.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.2 - 14 km ENE of Indio, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2328</th>\n",
|
||
" <td>1.80</td>\n",
|
||
" <td>70 km SE of Pedro Bay, Alaska</td>\n",
|
||
" <td>2025-03-17 00:10:04.935</td>\n",
|
||
" <td>2025-03-17 00:11:59.955</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,ak0253howj2l,</td>\n",
|
||
" <td>,ak,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>0.45</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.8 - 70 km SE of Pedro Bay, Alaska</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2329</th>\n",
|
||
" <td>1.75</td>\n",
|
||
" <td>2 km of The Geysers, CA</td>\n",
|
||
" <td>2025-03-17 00:09:46.390</td>\n",
|
||
" <td>2025-03-17 02:47:21.992</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75149791,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>21.0</td>\n",
|
||
" <td>0.007518</td>\n",
|
||
" <td>0.02</td>\n",
|
||
" <td>67.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.8 - 2 km of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2330</th>\n",
|
||
" <td>1.34</td>\n",
|
||
" <td>1 km NNW of The Geysers, CA</td>\n",
|
||
" <td>2025-03-17 00:08:45.280</td>\n",
|
||
" <td>2025-03-17 02:22:19.952</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75149786,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>11.0</td>\n",
|
||
" <td>0.013270</td>\n",
|
||
" <td>0.03</td>\n",
|
||
" <td>99.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.3 - 1 km NNW of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2331</th>\n",
|
||
" <td>0.65</td>\n",
|
||
" <td>4 km NNW of The Geysers, CA</td>\n",
|
||
" <td>2025-03-17 00:05:59.360</td>\n",
|
||
" <td>2025-03-17 17:56:00.796</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75149781,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>15.0</td>\n",
|
||
" <td>0.009786</td>\n",
|
||
" <td>0.01</td>\n",
|
||
" <td>80.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 0.7 - 4 km NNW of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2332</th>\n",
|
||
" <td>1.60</td>\n",
|
||
" <td>57 km S of Whites City, New Mexico</td>\n",
|
||
" <td>2025-03-17 00:04:47.952</td>\n",
|
||
" <td>2025-03-18 20:40:34.369</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,tx2025fhax,</td>\n",
|
||
" <td>,tx,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>17.0</td>\n",
|
||
" <td>0.100000</td>\n",
|
||
" <td>0.30</td>\n",
|
||
" <td>69.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.6 - 57 km S of Whites City, New Mexico</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>2333 rows × 26 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" mag place time \\\n",
|
||
"0 1.56 5 km NNW of Boron, CA 2025-03-23 23:56:23.000 \n",
|
||
"1 1.60 31 km NW of Toyah, Texas 2025-03-23 23:55:05.246 \n",
|
||
"2 1.70 6 km NNE of Windsor, CA 2025-03-23 23:52:39.960 \n",
|
||
"3 5.10 154 km ESE of Neiafu, Tonga 2025-03-23 23:36:24.213 \n",
|
||
"4 1.15 14 km ENE of Indio, CA 2025-03-23 23:35:52.810 \n",
|
||
"... ... ... ... \n",
|
||
"2328 1.80 70 km SE of Pedro Bay, Alaska 2025-03-17 00:10:04.935 \n",
|
||
"2329 1.75 2 km of The Geysers, CA 2025-03-17 00:09:46.390 \n",
|
||
"2330 1.34 1 km NNW of The Geysers, CA 2025-03-17 00:08:45.280 \n",
|
||
"2331 0.65 4 km NNW of The Geysers, CA 2025-03-17 00:05:59.360 \n",
|
||
"2332 1.60 57 km S of Whites City, New Mexico 2025-03-17 00:04:47.952 \n",
|
||
"\n",
|
||
" updated tz \\\n",
|
||
"0 2025-03-24 00:01:09.995 None \n",
|
||
"1 2025-03-24 15:17:33.050 None \n",
|
||
"2 2025-03-25 12:07:17.366 None \n",
|
||
"3 2025-03-24 01:09:53.040 None \n",
|
||
"4 2025-03-23 23:40:43.046 None \n",
|
||
"... ... ... \n",
|
||
"2328 2025-03-17 00:11:59.955 None \n",
|
||
"2329 2025-03-17 02:47:21.992 None \n",
|
||
"2330 2025-03-17 02:22:19.952 None \n",
|
||
"2331 2025-03-17 17:56:00.796 None \n",
|
||
"2332 2025-03-18 20:40:34.369 None \n",
|
||
"\n",
|
||
" url \\\n",
|
||
"0 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"1 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"3 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"4 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"... ... \n",
|
||
"2328 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2329 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2330 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2331 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2332 https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"\n",
|
||
" detail felt cdi mmi ... \\\n",
|
||
"0 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"1 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"3 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"4 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"... ... ... ... ... ... \n",
|
||
"2328 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2329 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2330 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2331 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2332 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"\n",
|
||
" ids sources \\\n",
|
||
"0 ,ci40908351, ,ci, \n",
|
||
"1 ,tx2025ftvc, ,tx, \n",
|
||
"2 ,nc75154137, ,nc, \n",
|
||
"3 ,us7000pm4g, ,us, \n",
|
||
"4 ,ci40908335, ,ci, \n",
|
||
"... ... ... \n",
|
||
"2328 ,ak0253howj2l, ,ak, \n",
|
||
"2329 ,nc75149791, ,nc, \n",
|
||
"2330 ,nc75149786, ,nc, \n",
|
||
"2331 ,nc75149781, ,nc, \n",
|
||
"2332 ,tx2025fhax, ,tx, \n",
|
||
"\n",
|
||
" types nst dmin rms \\\n",
|
||
"0 ,nearby-cities,origin,phase-data,scitech-link, 36.0 0.110000 0.20 \n",
|
||
"1 ,origin,phase-data, 14.0 0.000000 0.20 \n",
|
||
"2 ,focal-mechanism,nearby-cities,origin,phase-da... 64.0 0.074130 0.08 \n",
|
||
"3 ,origin,phase-data, 58.0 2.567000 0.88 \n",
|
||
"4 ,nearby-cities,origin,phase-data,scitech-link, 39.0 0.118400 0.19 \n",
|
||
"... ... ... ... ... \n",
|
||
"2328 ,origin,phase-data, NaN NaN 0.45 \n",
|
||
"2329 ,nearby-cities,origin,phase-data,scitech-link, 21.0 0.007518 0.02 \n",
|
||
"2330 ,nearby-cities,origin,phase-data,scitech-link, 11.0 0.013270 0.03 \n",
|
||
"2331 ,nearby-cities,origin,phase-data,scitech-link, 15.0 0.009786 0.01 \n",
|
||
"2332 ,origin,phase-data, 17.0 0.100000 0.30 \n",
|
||
"\n",
|
||
" gap magType type title \n",
|
||
"0 40.0 ml earthquake M 1.6 - 5 km NNW of Boron, CA \n",
|
||
"1 62.0 ml earthquake M 1.6 - 31 km NW of Toyah, Texas \n",
|
||
"2 45.0 md earthquake M 1.7 - 6 km NNE of Windsor, CA \n",
|
||
"3 62.0 mb earthquake M 5.1 - 154 km ESE of Neiafu, Tonga \n",
|
||
"4 47.0 ml earthquake M 1.2 - 14 km ENE of Indio, CA \n",
|
||
"... ... ... ... ... \n",
|
||
"2328 NaN ml earthquake M 1.8 - 70 km SE of Pedro Bay, Alaska \n",
|
||
"2329 67.0 md earthquake M 1.8 - 2 km of The Geysers, CA \n",
|
||
"2330 99.0 md earthquake M 1.3 - 1 km NNW of The Geysers, CA \n",
|
||
"2331 80.0 md earthquake M 0.7 - 4 km NNW of The Geysers, CA \n",
|
||
"2332 69.0 ml earthquake M 1.6 - 57 km S of Whites City, New Mexico \n",
|
||
"\n",
|
||
"[2333 rows x 26 columns]"
|
||
]
|
||
},
|
||
"execution_count": 199,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data['time'] = pd.to_datetime(data.time, unit='ms')\n",
|
||
"data['updated'] = pd.to_datetime(data.updated, unit='ms')\n",
|
||
"data"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 208,
|
||
"id": "5ad6604e-4dd4-40db-8758-aca82675baf2",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>place</th>\n",
|
||
" <th>tz</th>\n",
|
||
" <th>url</th>\n",
|
||
" <th>detail</th>\n",
|
||
" <th>alert</th>\n",
|
||
" <th>status</th>\n",
|
||
" <th>net</th>\n",
|
||
" <th>code</th>\n",
|
||
" <th>ids</th>\n",
|
||
" <th>sources</th>\n",
|
||
" <th>types</th>\n",
|
||
" <th>magType</th>\n",
|
||
" <th>type</th>\n",
|
||
" <th>title</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>count</th>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>17</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>unique</th>\n",
|
||
" <td>1430</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>16</td>\n",
|
||
" <td>2331</td>\n",
|
||
" <td>2333</td>\n",
|
||
" <td>54</td>\n",
|
||
" <td>37</td>\n",
|
||
" <td>8</td>\n",
|
||
" <td>4</td>\n",
|
||
" <td>2051</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>top</th>\n",
|
||
" <td>9 km NW of The Geysers, CA</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>green</td>\n",
|
||
" <td>reviewed</td>\n",
|
||
" <td>nc</td>\n",
|
||
" <td>2025frug</td>\n",
|
||
" <td>,tx2025fhax,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 0.8 - 7 km NW of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>freq</th>\n",
|
||
" <td>36</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>17</td>\n",
|
||
" <td>1603</td>\n",
|
||
" <td>544</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>533</td>\n",
|
||
" <td>1272</td>\n",
|
||
" <td>1470</td>\n",
|
||
" <td>2278</td>\n",
|
||
" <td>14</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" place tz \\\n",
|
||
"count 2333 0 \n",
|
||
"unique 1430 0 \n",
|
||
"top 9 km NW of The Geysers, CA NaN \n",
|
||
"freq 36 NaN \n",
|
||
"\n",
|
||
" url \\\n",
|
||
"count 2333 \n",
|
||
"unique 2333 \n",
|
||
"top https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"freq 1 \n",
|
||
"\n",
|
||
" detail alert status \\\n",
|
||
"count 2333 17 2333 \n",
|
||
"unique 2333 1 3 \n",
|
||
"top https://earthquake.usgs.gov/fdsnws/event/1/que... green reviewed \n",
|
||
"freq 1 17 1603 \n",
|
||
"\n",
|
||
" net code ids sources types magType \\\n",
|
||
"count 2333 2333 2333 2333 2333 2333 \n",
|
||
"unique 16 2331 2333 54 37 8 \n",
|
||
"top nc 2025frug ,tx2025fhax, ,nc, ,origin,phase-data, ml \n",
|
||
"freq 544 2 1 533 1272 1470 \n",
|
||
"\n",
|
||
" type title \n",
|
||
"count 2333 2333 \n",
|
||
"unique 4 2051 \n",
|
||
"top earthquake M 0.8 - 7 km NW of The Geysers, CA \n",
|
||
"freq 2278 14 "
|
||
]
|
||
},
|
||
"execution_count": 208,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data.describe(percentiles=[0.1,0.5,0.9])\n",
|
||
"data.describe(include='all')\n",
|
||
"data.describe(include=object)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 213,
|
||
"id": "b93408b0-5bdc-4350-8894-30d6fe199b92",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"type\n",
|
||
"earthquake 2278\n",
|
||
"quarry blast 33\n",
|
||
"explosion 19\n",
|
||
"ice quake 3\n",
|
||
"Name: count, dtype: int64"
|
||
]
|
||
},
|
||
"execution_count": 213,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data.type.value_counts()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "3e97cee2-0491-4ed2-84f1-b72f7b986fa2",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 197,
|
||
"id": "ca04e8f9-2005-432b-8607-a391f65eafb8",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>mag</th>\n",
|
||
" <th>place</th>\n",
|
||
" <th>time</th>\n",
|
||
" <th>updated</th>\n",
|
||
" <th>tz</th>\n",
|
||
" <th>url</th>\n",
|
||
" <th>detail</th>\n",
|
||
" <th>felt</th>\n",
|
||
" <th>cdi</th>\n",
|
||
" <th>mmi</th>\n",
|
||
" <th>...</th>\n",
|
||
" <th>ids</th>\n",
|
||
" <th>sources</th>\n",
|
||
" <th>types</th>\n",
|
||
" <th>nst</th>\n",
|
||
" <th>dmin</th>\n",
|
||
" <th>rms</th>\n",
|
||
" <th>gap</th>\n",
|
||
" <th>magType</th>\n",
|
||
" <th>type</th>\n",
|
||
" <th>title</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>1.56</td>\n",
|
||
" <td>5 km NNW of Boron, CA</td>\n",
|
||
" <td>2025-03-23 23:56:23.000</td>\n",
|
||
" <td>1742774469995</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,ci40908351,</td>\n",
|
||
" <td>,ci,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>36.0</td>\n",
|
||
" <td>0.110000</td>\n",
|
||
" <td>0.20</td>\n",
|
||
" <td>40.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.6 - 5 km NNW of Boron, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>1.60</td>\n",
|
||
" <td>31 km NW of Toyah, Texas</td>\n",
|
||
" <td>2025-03-23 23:55:05.246</td>\n",
|
||
" <td>1742829453050</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,tx2025ftvc,</td>\n",
|
||
" <td>,tx,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>14.0</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" <td>0.20</td>\n",
|
||
" <td>62.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.6 - 31 km NW of Toyah, Texas</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>1.70</td>\n",
|
||
" <td>6 km NNE of Windsor, CA</td>\n",
|
||
" <td>2025-03-23 23:52:39.960</td>\n",
|
||
" <td>1742904437366</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75154137,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,focal-mechanism,nearby-cities,origin,phase-da...</td>\n",
|
||
" <td>64.0</td>\n",
|
||
" <td>0.074130</td>\n",
|
||
" <td>0.08</td>\n",
|
||
" <td>45.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.7 - 6 km NNE of Windsor, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>5.10</td>\n",
|
||
" <td>154 km ESE of Neiafu, Tonga</td>\n",
|
||
" <td>2025-03-23 23:36:24.213</td>\n",
|
||
" <td>1742778593040</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,us7000pm4g,</td>\n",
|
||
" <td>,us,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>58.0</td>\n",
|
||
" <td>2.567000</td>\n",
|
||
" <td>0.88</td>\n",
|
||
" <td>62.0</td>\n",
|
||
" <td>mb</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 5.1 - 154 km ESE of Neiafu, Tonga</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>1.15</td>\n",
|
||
" <td>14 km ENE of Indio, CA</td>\n",
|
||
" <td>2025-03-23 23:35:52.810</td>\n",
|
||
" <td>1742773243046</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,ci40908335,</td>\n",
|
||
" <td>,ci,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>39.0</td>\n",
|
||
" <td>0.118400</td>\n",
|
||
" <td>0.19</td>\n",
|
||
" <td>47.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.2 - 14 km ENE of Indio, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2328</th>\n",
|
||
" <td>1.80</td>\n",
|
||
" <td>70 km SE of Pedro Bay, Alaska</td>\n",
|
||
" <td>2025-03-17 00:10:04.935</td>\n",
|
||
" <td>1742170319955</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,ak0253howj2l,</td>\n",
|
||
" <td>,ak,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>0.45</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.8 - 70 km SE of Pedro Bay, Alaska</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2329</th>\n",
|
||
" <td>1.75</td>\n",
|
||
" <td>2 km of The Geysers, CA</td>\n",
|
||
" <td>2025-03-17 00:09:46.390</td>\n",
|
||
" <td>1742179641992</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75149791,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>21.0</td>\n",
|
||
" <td>0.007518</td>\n",
|
||
" <td>0.02</td>\n",
|
||
" <td>67.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.8 - 2 km of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2330</th>\n",
|
||
" <td>1.34</td>\n",
|
||
" <td>1 km NNW of The Geysers, CA</td>\n",
|
||
" <td>2025-03-17 00:08:45.280</td>\n",
|
||
" <td>1742178139952</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75149786,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>11.0</td>\n",
|
||
" <td>0.013270</td>\n",
|
||
" <td>0.03</td>\n",
|
||
" <td>99.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.3 - 1 km NNW of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2331</th>\n",
|
||
" <td>0.65</td>\n",
|
||
" <td>4 km NNW of The Geysers, CA</td>\n",
|
||
" <td>2025-03-17 00:05:59.360</td>\n",
|
||
" <td>1742234160796</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,nc75149781,</td>\n",
|
||
" <td>,nc,</td>\n",
|
||
" <td>,nearby-cities,origin,phase-data,scitech-link,</td>\n",
|
||
" <td>15.0</td>\n",
|
||
" <td>0.009786</td>\n",
|
||
" <td>0.01</td>\n",
|
||
" <td>80.0</td>\n",
|
||
" <td>md</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 0.7 - 4 km NNW of The Geysers, CA</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2332</th>\n",
|
||
" <td>1.60</td>\n",
|
||
" <td>57 km S of Whites City, New Mexico</td>\n",
|
||
" <td>2025-03-17 00:04:47.952</td>\n",
|
||
" <td>1742330434369</td>\n",
|
||
" <td>None</td>\n",
|
||
" <td>https://earthquake.usgs.gov/earthquakes/eventp...</td>\n",
|
||
" <td>https://earthquake.usgs.gov/fdsnws/event/1/que...</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>NaN</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>,tx2025fhax,</td>\n",
|
||
" <td>,tx,</td>\n",
|
||
" <td>,origin,phase-data,</td>\n",
|
||
" <td>17.0</td>\n",
|
||
" <td>0.100000</td>\n",
|
||
" <td>0.30</td>\n",
|
||
" <td>69.0</td>\n",
|
||
" <td>ml</td>\n",
|
||
" <td>earthquake</td>\n",
|
||
" <td>M 1.6 - 57 km S of Whites City, New Mexico</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>2333 rows × 26 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" mag place time \\\n",
|
||
"0 1.56 5 km NNW of Boron, CA 2025-03-23 23:56:23.000 \n",
|
||
"1 1.60 31 km NW of Toyah, Texas 2025-03-23 23:55:05.246 \n",
|
||
"2 1.70 6 km NNE of Windsor, CA 2025-03-23 23:52:39.960 \n",
|
||
"3 5.10 154 km ESE of Neiafu, Tonga 2025-03-23 23:36:24.213 \n",
|
||
"4 1.15 14 km ENE of Indio, CA 2025-03-23 23:35:52.810 \n",
|
||
"... ... ... ... \n",
|
||
"2328 1.80 70 km SE of Pedro Bay, Alaska 2025-03-17 00:10:04.935 \n",
|
||
"2329 1.75 2 km of The Geysers, CA 2025-03-17 00:09:46.390 \n",
|
||
"2330 1.34 1 km NNW of The Geysers, CA 2025-03-17 00:08:45.280 \n",
|
||
"2331 0.65 4 km NNW of The Geysers, CA 2025-03-17 00:05:59.360 \n",
|
||
"2332 1.60 57 km S of Whites City, New Mexico 2025-03-17 00:04:47.952 \n",
|
||
"\n",
|
||
" updated tz url \\\n",
|
||
"0 1742774469995 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"1 1742829453050 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2 1742904437366 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"3 1742778593040 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"4 1742773243046 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"... ... ... ... \n",
|
||
"2328 1742170319955 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2329 1742179641992 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2330 1742178139952 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2331 1742234160796 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"2332 1742330434369 None https://earthquake.usgs.gov/earthquakes/eventp... \n",
|
||
"\n",
|
||
" detail felt cdi mmi ... \\\n",
|
||
"0 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"1 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"3 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"4 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"... ... ... ... ... ... \n",
|
||
"2328 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2329 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2330 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2331 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"2332 https://earthquake.usgs.gov/fdsnws/event/1/que... NaN NaN NaN ... \n",
|
||
"\n",
|
||
" ids sources \\\n",
|
||
"0 ,ci40908351, ,ci, \n",
|
||
"1 ,tx2025ftvc, ,tx, \n",
|
||
"2 ,nc75154137, ,nc, \n",
|
||
"3 ,us7000pm4g, ,us, \n",
|
||
"4 ,ci40908335, ,ci, \n",
|
||
"... ... ... \n",
|
||
"2328 ,ak0253howj2l, ,ak, \n",
|
||
"2329 ,nc75149791, ,nc, \n",
|
||
"2330 ,nc75149786, ,nc, \n",
|
||
"2331 ,nc75149781, ,nc, \n",
|
||
"2332 ,tx2025fhax, ,tx, \n",
|
||
"\n",
|
||
" types nst dmin rms \\\n",
|
||
"0 ,nearby-cities,origin,phase-data,scitech-link, 36.0 0.110000 0.20 \n",
|
||
"1 ,origin,phase-data, 14.0 0.000000 0.20 \n",
|
||
"2 ,focal-mechanism,nearby-cities,origin,phase-da... 64.0 0.074130 0.08 \n",
|
||
"3 ,origin,phase-data, 58.0 2.567000 0.88 \n",
|
||
"4 ,nearby-cities,origin,phase-data,scitech-link, 39.0 0.118400 0.19 \n",
|
||
"... ... ... ... ... \n",
|
||
"2328 ,origin,phase-data, NaN NaN 0.45 \n",
|
||
"2329 ,nearby-cities,origin,phase-data,scitech-link, 21.0 0.007518 0.02 \n",
|
||
"2330 ,nearby-cities,origin,phase-data,scitech-link, 11.0 0.013270 0.03 \n",
|
||
"2331 ,nearby-cities,origin,phase-data,scitech-link, 15.0 0.009786 0.01 \n",
|
||
"2332 ,origin,phase-data, 17.0 0.100000 0.30 \n",
|
||
"\n",
|
||
" gap magType type title \n",
|
||
"0 40.0 ml earthquake M 1.6 - 5 km NNW of Boron, CA \n",
|
||
"1 62.0 ml earthquake M 1.6 - 31 km NW of Toyah, Texas \n",
|
||
"2 45.0 md earthquake M 1.7 - 6 km NNE of Windsor, CA \n",
|
||
"3 62.0 mb earthquake M 5.1 - 154 km ESE of Neiafu, Tonga \n",
|
||
"4 47.0 ml earthquake M 1.2 - 14 km ENE of Indio, CA \n",
|
||
"... ... ... ... ... \n",
|
||
"2328 NaN ml earthquake M 1.8 - 70 km SE of Pedro Bay, Alaska \n",
|
||
"2329 67.0 md earthquake M 1.8 - 2 km of The Geysers, CA \n",
|
||
"2330 99.0 md earthquake M 1.3 - 1 km NNW of The Geysers, CA \n",
|
||
"2331 80.0 md earthquake M 0.7 - 4 km NNW of The Geysers, CA \n",
|
||
"2332 69.0 ml earthquake M 1.6 - 57 km S of Whites City, New Mexico \n",
|
||
"\n",
|
||
"[2333 rows x 26 columns]"
|
||
]
|
||
},
|
||
"execution_count": 197,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data.to_csv(\"data/out.csv\")"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "aeea3f8b-4856-4ba5-83dd-f6b0f4aa3747",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true
|
||
},
|
||
"source": [
|
||
"# Losowość"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 97,
|
||
"id": "d114c181-cb51-4e7d-ab7c-e1033c6f1916",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"0 0.068324\n",
|
||
"1 0.228807\n",
|
||
"2 0.424159\n",
|
||
"3 0.288747\n",
|
||
"4 0.091950\n",
|
||
"5 0.017583\n",
|
||
"6 0.832726\n",
|
||
"7 0.191866\n",
|
||
"8 0.969317\n",
|
||
"9 0.795694\n",
|
||
"10 0.385554\n",
|
||
"11 0.614211\n",
|
||
"12 0.881981\n",
|
||
"13 0.157185\n",
|
||
"14 0.908872\n",
|
||
"dtype: float64"
|
||
]
|
||
},
|
||
"execution_count": 97,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"import time\n",
|
||
"np.random.seed(int(time.time()))\n",
|
||
"x = np.random.rand(15)\n",
|
||
"pd.Series(x)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 106,
|
||
"id": "b5f7817b-a68d-4c6a-a16d-ffbe25e76156",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>random</th>\n",
|
||
" <th>text</th>\n",
|
||
" <th>truth</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>2025-03-01</th>\n",
|
||
" <td>0.693064</td>\n",
|
||
" <td>foo</td>\n",
|
||
" <td>True</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2025-03-02</th>\n",
|
||
" <td>0.473443</td>\n",
|
||
" <td>bar</td>\n",
|
||
" <td>True</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2025-03-03</th>\n",
|
||
" <td>0.877936</td>\n",
|
||
" <td>baz</td>\n",
|
||
" <td>True</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" random text truth\n",
|
||
"2025-03-01 0.693064 foo True\n",
|
||
"2025-03-02 0.473443 bar True\n",
|
||
"2025-03-03 0.877936 baz True"
|
||
]
|
||
},
|
||
"execution_count": 106,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"data = pd.DataFrame({\n",
|
||
" \"random\": np.random.rand(5),\n",
|
||
" \"text\": [\"foo\", \"bar\", \"baz\", \"car\", \"txt\"],\n",
|
||
" \"truth\": [np.random.choice((True, False)) for _ in range(5)]\n",
|
||
"}, index = pd.date_range(\"2025-03-01\", periods=5, freq=\"D\")\n",
|
||
")\n",
|
||
"\n",
|
||
"data[data[\"truth\"] == True]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 118,
|
||
"id": "c8f5fba4-76fe-4b0a-bbc0-e2c5114a769b",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>0</th>\n",
|
||
" <th>1</th>\n",
|
||
" <th>2</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4</td>\n",
|
||
" <td>4</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>3</td>\n",
|
||
" <td>9</td>\n",
|
||
" <td>6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>4</td>\n",
|
||
" <td>16</td>\n",
|
||
" <td>8</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" 0 1 2\n",
|
||
"0 0 0 0\n",
|
||
"1 1 1 2\n",
|
||
"2 2 4 4\n",
|
||
"3 3 9 6\n",
|
||
"4 4 16 8"
|
||
]
|
||
},
|
||
"execution_count": 118,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"tuple = [(n, n**2, n*2) for n in range(5)]\n",
|
||
"pd.DataFrame(tuple)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "c5d2e71f-0ce7-4329-afad-bb50a5f31dc2",
|
||
"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.12.9"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 5
|
||
}
|