{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "cce98b30", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "id": "1d0aceb5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
tanggaljumlah_penumpang_per_hari
02024-01-013166
12024-01-022901
22024-01-032795
32024-01-042784
42024-01-053219
.........
6042025-08-273702
6052025-08-283412
6062025-08-293201
6072025-08-302406
6082025-08-312091
\n", "

609 rows × 2 columns

\n", "
" ], "text/plain": [ " tanggal jumlah_penumpang_per_hari\n", "0 2024-01-01 3166\n", "1 2024-01-02 2901\n", "2 2024-01-03 2795\n", "3 2024-01-04 2784\n", "4 2024-01-05 3219\n", ".. ... ...\n", "604 2025-08-27 3702\n", "605 2025-08-28 3412\n", "606 2025-08-29 3201\n", "607 2025-08-30 2406\n", "608 2025-08-31 2091\n", "\n", "[609 rows x 2 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv('lrt_daily.csv', sep=';', decimal=',')\n", "df['tanggal'] = pd.to_datetime(df['tanggal'], format='%Y-%m-%d')\n", "df" ] }, { "cell_type": "code", "execution_count": null, "id": "e6183452", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
tanggaljumlah_penumpang_per_hariweekday_numweekdayis_weekendholiday_nameis_holiday_nat
02024-01-0131660Monday0Tahun Baru Masehi1
12024-01-0229011Tuesday0None0
22024-01-0327952Wednesday0None0
32024-01-0427843Thursday0None0
42024-01-0532194Friday0None0
........................
6042025-08-2737022Wednesday0None0
6052025-08-2834123Thursday0None0
6062025-08-2932014Friday0None0
6072025-08-3024065Saturday1None0
6082025-08-3120916Sunday1None0
\n", "

609 rows × 7 columns

\n", "
" ], "text/plain": [ " tanggal jumlah_penumpang_per_hari weekday_num weekday is_weekend \\\n", "0 2024-01-01 3166 0 Monday 0 \n", "1 2024-01-02 2901 1 Tuesday 0 \n", "2 2024-01-03 2795 2 Wednesday 0 \n", "3 2024-01-04 2784 3 Thursday 0 \n", "4 2024-01-05 3219 4 Friday 0 \n", ".. ... ... ... ... ... \n", "604 2025-08-27 3702 2 Wednesday 0 \n", "605 2025-08-28 3412 3 Thursday 0 \n", "606 2025-08-29 3201 4 Friday 0 \n", "607 2025-08-30 2406 5 Saturday 1 \n", "608 2025-08-31 2091 6 Sunday 1 \n", "\n", " holiday_name is_holiday_nat \n", "0 Tahun Baru Masehi 1 \n", "1 None 0 \n", "2 None 0 \n", "3 None 0 \n", "4 None 0 \n", ".. ... ... \n", "604 None 0 \n", "605 None 0 \n", "606 None 0 \n", "607 None 0 \n", "608 None 0 \n", "\n", "[609 rows x 7 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Flag Indonesian national holidays and weekends (Saturday/Sunday)\n", "\n", "import pandas as pd\n", "\n", "# --- choose your date source: either index or a 'tanggal' column\n", "# If your df has 'tanggal' column:\n", "if \"tanggal\" in df.columns:\n", " dates = pd.to_datetime(df[\"tanggal\"])\n", " df = df.copy()\n", "else:\n", " # assume DatetimeIndex\n", " if not isinstance(df.index, pd.DatetimeIndex):\n", " raise ValueError(\"Provide a DatetimeIndex or a 'tanggal' column.\")\n", " dates = pd.to_datetime(df.index)\n", " df = df.copy()\n", " df[\"tanggal\"] = dates\n", "\n", "# --- weekday flags\n", "df[\"weekday_num\"] = dates.dt.weekday # 0=Mon ... 6=Sun\n", "df[\"weekday\"] = dates.dt.day_name() # e.g., 'Monday'\n", "df[\"is_weekend\"] = df[\"weekday_num\"].isin([5, 6]).astype(int) # 1=Sat/Sun\n", "\n", "# --- Indonesian national holidays (by year span present in df)\n", "try:\n", " import holidays\n", "except ImportError:\n", " import sys, subprocess\n", " subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"holidays\"])\n", " import holidays\n", "\n", "years = sorted(set(dates.dt.year))\n", "id_hdays = holidays.country_holidays(\"ID\", years=years)\n", "\n", "# map holiday name (None if not a holiday), then binary flag\n", "df[\"holiday_name\"] = dates.map(lambda d: id_hdays.get(d, None))\n", "df[\"is_holiday_nat\"] = df[\"holiday_name\"].notna().astype(int)\n", "\n", "# (optional) keep only new columns if you prefer:\n", "# df_flags = df[[\"tanggal\", \"weekday_num\", \"weekday\", \"is_weekend\", \"holiday_name\", \"is_holiday_nat\"]]\n", "\n", "# quick sanity check\n", "df.drop(columns=['weekday_num', 'weekday', 'holiday_name']).head(10)\n", "df\n" ] }, { "cell_type": "code", "execution_count": null, "id": "ab914ade", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
tanggalis_weekendis_holiday_natis_offoff_block_idoff_block_lenflag_contiguous_offflag_almost_contiguous_off
02024-01-010110100
12024-01-02000-1000
22024-01-03000-1000
32024-01-04000-1000
42024-01-05000-1000
...........................
6042025-08-27000-1000
6052025-08-28000-1000
6062025-08-29000-1000
6072025-08-3010199200
6082025-08-3110199200
\n", "

609 rows × 8 columns

\n", "
" ], "text/plain": [ " tanggal is_weekend is_holiday_nat is_off off_block_id \\\n", "0 2024-01-01 0 1 1 0 \n", "1 2024-01-02 0 0 0 -1 \n", "2 2024-01-03 0 0 0 -1 \n", "3 2024-01-04 0 0 0 -1 \n", "4 2024-01-05 0 0 0 -1 \n", ".. ... ... ... ... ... \n", "604 2025-08-27 0 0 0 -1 \n", "605 2025-08-28 0 0 0 -1 \n", "606 2025-08-29 0 0 0 -1 \n", "607 2025-08-30 1 0 1 99 \n", "608 2025-08-31 1 0 1 99 \n", "\n", " off_block_len flag_contiguous_off flag_almost_contiguous_off \n", "0 1 0 0 \n", "1 0 0 0 \n", "2 0 0 0 \n", "3 0 0 0 \n", "4 0 0 0 \n", ".. ... ... ... \n", "604 0 0 0 \n", "605 0 0 0 \n", "606 0 0 0 \n", "607 2 0 0 \n", "608 2 0 0 \n", "\n", "[609 rows x 8 columns]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'flag_contiguous_off': 31, 'flag_almost_contiguous_off': 23}\n" ] } ], "source": [ "# --- Build unified off-day flags, contiguous (≥3) and “almost contiguous” (off–off–ON–off) ---\n", "\n", "import pandas as pd\n", "import numpy as np\n", "\n", "# Preconditions:\n", "# df has columns:\n", "# - 'tanggal' (datetime-like)\n", "# - 'is_weekend' (0/1)\n", "# - 'is_holiday_nat' (0/1)\n", "\n", "df = df.copy().sort_values(\"tanggal\")\n", "df[\"tanggal\"] = pd.to_datetime(df[\"tanggal\"])\n", "\n", "# 1) Melt weekend & national holiday into one OFF flag\n", "df[\"is_off\"] = ((df[\"is_weekend\"].astype(int) == 1) | (df[\"is_holiday_nat\"].astype(int) == 1)).astype(int)\n", "\n", "# 2) Reindex to DAILY so we can assess contiguity properly\n", "full_idx = pd.date_range(df[\"tanggal\"].min(), df[\"tanggal\"].max(), freq=\"D\")\n", "tmp = pd.DataFrame(index=full_idx).rename_axis(\"tanggal\").reset_index()\n", "tmp = tmp.merge(df[[\"tanggal\",\"is_off\"]], on=\"tanggal\", how=\"left\")\n", "tmp[\"is_off\"] = tmp[\"is_off\"].fillna(0).astype(int)\n", "\n", "# 3) Contiguous off-day blocks (run-length on is_off==1)\n", "block_id = []\n", "curr_id, prev_off = -1, False\n", "for flag in tmp[\"is_off\"].tolist():\n", " if flag == 1 and not prev_off:\n", " curr_id += 1\n", " block_id.append(curr_id if flag == 1 else -1)\n", " prev_off = (flag == 1)\n", "\n", "tmp[\"off_block_id\"] = block_id\n", "\n", "# length of each off block\n", "off_len = (tmp[tmp[\"off_block_id\"] >= 0]\n", " .groupby(\"off_block_id\").size()\n", " .rename(\"off_block_len\"))\n", "\n", "tmp = tmp.merge(off_len, left_on=\"off_block_id\", right_index=True, how=\"left\")\n", "tmp[\"off_block_len\"] = tmp[\"off_block_len\"].fillna(0).astype(int)\n", "\n", "# 4) Flag contiguous holidays: member of an off block with length ≥ 3\n", "tmp[\"flag_contiguous_off\"] = ((tmp[\"is_off\"] == 1) & (tmp[\"off_block_len\"] >= 3)).astype(int)\n", "\n", "# 5) Flag “almost contiguous” holidays:\n", "# Definition: a single ON day (0) *between* OFF days (1-0-1); we mark the OFF days on both sides.\n", "# Steps:\n", "# a) Find bridge days where pattern prev=1, curr=0, next=1 (1-0-1).\n", "# b) For each bridge, expand to the left/right to capture the adjacent off-blocks, and mark their members.\n", "\n", "is_off = tmp[\"is_off\"].values\n", "prev_off = np.r_[False, is_off[:-1] == 1]\n", "next_off = np.r_[is_off[1:] == 1, False]\n", "bridge_mask = (is_off == 0) & prev_off & next_off # positions of the single-day gap\n", "\n", "# initialize mask for almost contiguous membership (OFF days that belong to a 1-0-1 structure)\n", "almost_mask = np.zeros(len(tmp), dtype=bool)\n", "\n", "if bridge_mask.any():\n", " bridge_idx = np.where(bridge_mask)[0]\n", " for b in bridge_idx:\n", " # expand left over the contiguous OFF block\n", " L = b - 1\n", " while L >= 0 and is_off[L] == 1:\n", " almost_mask[L] = True\n", " L -= 1\n", " # expand right over the contiguous OFF block\n", " R = b + 1\n", " while R < len(tmp) and is_off[R] == 1:\n", " almost_mask[R] = True\n", " R += 1\n", "\n", "# Only OFF days can be “almost contiguous” members\n", "tmp[\"flag_almost_contiguous_off\"] = (almost_mask & (tmp[\"is_off\"] == 1)).astype(int)\n", "\n", "# 6) Bring flags back to your original rows\n", "df_flags = (df[[\"tanggal\",\"is_weekend\",\"is_holiday_nat\"]]\n", " .merge(tmp[[\"tanggal\",\"is_off\",\"off_block_id\",\"off_block_len\",\n", " \"flag_contiguous_off\",\"flag_almost_contiguous_off\"]],\n", " on=\"tanggal\", how=\"left\"))\n", "\n", "# 7) (optional) quick sanity checks\n", "df_flags.drop(columns=['is_off', 'off_block_id', 'off_block_len'])\n", "display(df_flags)\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "bc367e11", "metadata": {}, "outputs": [], "source": [ "df_flags.drop(columns=['is_off', 'off_block_id', 'off_block_len'], inplace=True)" ] }, { "cell_type": "code", "execution_count": 6, "id": "21db4425", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
tanggalis_weekendis_holiday_natflag_contiguous_offflag_almost_contiguous_off
02024-01-010100
12024-01-020000
22024-01-030000
32024-01-040000
42024-01-050000
..................
6042025-08-270000
6052025-08-280000
6062025-08-290000
6072025-08-301000
6082025-08-311000
\n", "

609 rows × 5 columns

\n", "
" ], "text/plain": [ " tanggal is_weekend is_holiday_nat flag_contiguous_off \\\n", "0 2024-01-01 0 1 0 \n", "1 2024-01-02 0 0 0 \n", "2 2024-01-03 0 0 0 \n", "3 2024-01-04 0 0 0 \n", "4 2024-01-05 0 0 0 \n", ".. ... ... ... ... \n", "604 2025-08-27 0 0 0 \n", "605 2025-08-28 0 0 0 \n", "606 2025-08-29 0 0 0 \n", "607 2025-08-30 1 0 0 \n", "608 2025-08-31 1 0 0 \n", "\n", " flag_almost_contiguous_off \n", "0 0 \n", "1 0 \n", "2 0 \n", "3 0 \n", "4 0 \n", ".. ... \n", "604 0 \n", "605 0 \n", "606 0 \n", "607 0 \n", "608 0 \n", "\n", "[609 rows x 5 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_flags" ] }, { "cell_type": "code", "execution_count": 7, "id": "6d711449", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'contiguous_>=3': 31, 'almost_1-0-1': 23, 'almost_LONG (≥2 on one side)': 23}\n", " tanggal is_off\n", "2024-02-08 1\n", "2024-02-10 1\n", "2024-02-11 1\n", "2024-04-10 1\n", "2024-04-11 1\n", "2024-04-13 1\n", "2024-04-14 1\n", "2024-05-09 1\n", "2024-05-11 1\n", "2024-05-12 1\n", "2024-05-23 1\n", "2024-05-25 1\n", "2024-05-26 1\n", "2025-01-25 1\n", "2025-01-26 1\n" ] } ], "source": [ "# --- Stronger-than-\"almost\" contiguous off-days: require ≥2 consecutive OFFs on either side of a 1-day gap\n", "# Pattern examples it should capture (at least):\n", "# 1-1-0-1 or 1-0-1-1\n", "# and also longer variants like 1-1-1-0-1, 1-0-1-1-1, etc.\n", "\n", "import numpy as np\n", "import pandas as pd\n", "\n", "# Preconditions from previous cell:\n", "# - `tmp` has a DAILY row per date with:\n", "# tmp[\"tanggal\"] (Datetime), tmp[\"is_off\"] ∈ {0,1}\n", "# - We already computed `flag_contiguous_off` and `flag_almost_contiguous_off`\n", "# If not, rebuild `tmp` & `is_off` from your df the same way as before.\n", "\n", "is_off = tmp[\"is_off\"].to_numpy(dtype=int)\n", "\n", "# Identify 1-day gaps between OFF blocks (the same \"bridge\" as earlier: 1-0-1)\n", "prev_off = np.r_[False, is_off[:-1] == 1]\n", "next_off = np.r_[is_off[1:] == 1, False]\n", "bridge_mask = (is_off == 0) & prev_off & next_off\n", "\n", "# Helper: count consecutive OFFs immediately to the left/right of a given index\n", "def count_run_left(arr, i):\n", " c = 0\n", " j = i - 1\n", " while j >= 0 and arr[j] == 1:\n", " c += 1\n", " j -= 1\n", " return c\n", "\n", "def count_run_right(arr, i):\n", " c = 0\n", " j = i + 1\n", " n = len(arr)\n", " while j < n and arr[j] == 1:\n", " c += 1\n", " j += 1\n", " return c\n", "\n", "# Build mask for \"almost long contiguous\" OFF days:\n", "# Mark OFF days adjacent to bridges where left or right OFF-run length ≥ 2\n", "almost_long_mask = np.zeros(len(tmp), dtype=bool)\n", "\n", "bridge_idx = np.where(bridge_mask)[0]\n", "for b in bridge_idx:\n", " Lrun = count_run_left(is_off, b)\n", " Rrun = count_run_right(is_off, b)\n", " if max(Lrun, Rrun) >= 2:\n", " # expand left over its OFF block\n", " L = b - 1\n", " while L >= 0 and is_off[L] == 1:\n", " almost_long_mask[L] = True\n", " L -= 1\n", " # expand right over its OFF block\n", " R = b + 1\n", " while R < len(is_off) and is_off[R] == 1:\n", " almost_long_mask[R] = True\n", " R += 1\n", "\n", "# Only OFF days can be flagged\n", "tmp[\"flag_almost_long_contiguous_off\"] = (almost_long_mask & (tmp[\"is_off\"] == 1)).astype(int)\n", "\n", "# Merge back to your main flag table if needed\n", "df_flags = (df_flags\n", " .merge(tmp[[\"tanggal\", \"flag_almost_long_contiguous_off\"]],\n", " on=\"tanggal\", how=\"left\"))\n", "\n", "# Quick check of totals\n", "print({\n", " \"contiguous_>=3\": int(tmp[\"flag_contiguous_off\"].sum()),\n", " \"almost_1-0-1\": int(tmp[\"flag_almost_contiguous_off\"].sum()),\n", " \"almost_LONG (≥2 on one side)\": int(tmp[\"flag_almost_long_contiguous_off\"].sum())\n", "})\n", "\n", "# Optional: inspect a few segments where the new flag is set\n", "sample = tmp.loc[tmp[\"flag_almost_long_contiguous_off\"]==1, [\"tanggal\",\"is_off\"]].head(15)\n", "print(sample.to_string(index=False))\n" ] }, { "cell_type": "code", "execution_count": 8, "id": "badd65ed", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
tanggalis_weekendis_holiday_natflag_contiguous_offflag_almost_contiguous_offflag_almost_long_contiguous_off
02024-01-0101000
12024-01-0200000
22024-01-0300000
32024-01-0400000
42024-01-0500000
.....................
6042025-08-2700000
6052025-08-2800000
6062025-08-2900000
6072025-08-3010000
6082025-08-3110000
\n", "

609 rows × 6 columns

\n", "
" ], "text/plain": [ " tanggal is_weekend is_holiday_nat flag_contiguous_off \\\n", "0 2024-01-01 0 1 0 \n", "1 2024-01-02 0 0 0 \n", "2 2024-01-03 0 0 0 \n", "3 2024-01-04 0 0 0 \n", "4 2024-01-05 0 0 0 \n", ".. ... ... ... ... \n", "604 2025-08-27 0 0 0 \n", "605 2025-08-28 0 0 0 \n", "606 2025-08-29 0 0 0 \n", "607 2025-08-30 1 0 0 \n", "608 2025-08-31 1 0 0 \n", "\n", " flag_almost_contiguous_off flag_almost_long_contiguous_off \n", "0 0 0 \n", "1 0 0 \n", "2 0 0 \n", "3 0 0 \n", "4 0 0 \n", ".. ... ... \n", "604 0 0 \n", "605 0 0 \n", "606 0 0 \n", "607 0 0 \n", "608 0 0 \n", "\n", "[609 rows x 6 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_flags" ] }, { "cell_type": "code", "execution_count": 9, "id": "b000a5e1", "metadata": {}, "outputs": [], "source": [ "df_flags.to_csv('lrt_offday_flags.csv', index=False)" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.0" } }, "nbformat": 4, "nbformat_minor": 5 }