{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "13c6141d",
   "metadata": {},
   "source": [
    "# Behavioral Clustering of Carmignac Investors\n",
    "## FUND LEVEL \n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28e588fe",
   "metadata": {},
   "source": [
    "---\n",
    "## 1. Imports \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3bc1ffe0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import re\n",
    "import s3fs\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "from sklearn.preprocessing import RobustScaler\n",
    "from sklearn.cluster import KMeans\n",
    "from sklearn.metrics import silhouette_score, davies_bouldin_score\n",
    "\n",
    "sns.set_style(\"whitegrid\")\n",
    "pd.set_option(\"display.max_columns\", 200)\n",
    "pd.set_option(\"display.max_rows\", 200)\n",
    "\n",
    "EPS = 1e-9\n",
    "RANDOM_STATE = 42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "69d2dc25",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Column names\n",
    "ID_COL        = \"Registrar Account - ID\"\n",
    "ISIN_COL      = \"Product - Isin\"\n",
    "FUND_COL      = \"Product - Fund\"\n",
    "ASSET_COL     = \"Product - Asset Type\"\n",
    "FLOW_DATE_COL = \"Centralisation Date\"\n",
    "AUM_DATE_COL  = \"Centralisation Date\"\n",
    "FLOW_QTY_COL  = \"Quantity - NetFlows\"\n",
    "FLOW_SUB_COL  = \"Quantity - Subscription\"\n",
    "FLOW_RED_COL  = \"Quantity - Redemption\"\n",
    "AUM_QTY_COL   = \"Quantity - AUM\"\n",
    "AUM_VAL_COL   = \"Value - AUM €\"\n",
    "REGION_COL    = \"Registrar Account - Region\"\n",
    "COUNTRY_COL   = \"RegistrarAccount - Country\"\n",
    "NAV_DATE_COL  = \"Dat\"\n",
    "NAV_ISIN_COL  = \"Isin\"\n",
    "NAV_PRICE_COL = \"Price (TF PartPrice)\"\n",
    "NAV_BENCH_COL = \"PriceBench\"\n",
    "RATE_DATE_COL = \"Date\"\n",
    "RATE_VAL_COL  = \"Yld to Maturity\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bf5b7a0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# SHARED UTILITIES\n",
    "def robust_zscore(s):\n",
    "    med = np.nanmedian(s)\n",
    "    mad = np.nanmedian(np.abs(s - med))\n",
    "    if mad == 0 or np.isnan(mad):\n",
    "        return np.zeros(len(s))\n",
    "    return (s - med) / (1.4826 * mad)\n",
    "\n",
    "def plot_heatmap(dfc, profile_vars, cluster_col, title, figsize=(16, 4)):\n",
    "    \"\"\"Cluster signature heatmap using robust z-scores, capped at ±3 for readability.\"\"\"\n",
    "    dfc_viz = dfc[profile_vars + [cluster_col]].copy()\n",
    "    for col in profile_vars:\n",
    "        vals = pd.to_numeric(dfc_viz[col], errors=\"coerce\").to_numpy(dtype=float)\n",
    "        lo = np.nanpercentile(vals, 2)\n",
    "        hi = np.nanpercentile(vals, 98)\n",
    "        dfc_viz[col] = np.clip(vals, lo, hi)\n",
    "    prof   = dfc_viz.groupby(cluster_col)[profile_vars].median()\n",
    "    prof_z = prof.apply(lambda col: robust_zscore(col.values), axis=0)\n",
    "    prof_z = prof_z.clip(-3, 3)   # cap for readability\n",
    "    plt.figure(figsize=figsize)\n",
    "    sns.heatmap(prof_z, cmap=\"RdBu_r\", center=0, annot=True, fmt=\".2f\",\n",
    "                xticklabels=profile_vars,\n",
    "                yticklabels=[f\"Cluster {i}\" for i in range(len(prof))])\n",
    "    plt.title(title)\n",
    "    plt.xticks(rotation=45, ha=\"right\")\n",
    "    plt.tight_layout()\n",
    "    plt.show()\n",
    "    return prof\n",
    "\n",
    "def winsorize_mad(series, n_sigma=3):\n",
    "    \"\"\"Winsorize using MAD n-sigma rule. Falls back to p95 clip when MAD~0.\"\"\"\n",
    "    vals = pd.to_numeric(series, errors=\"coerce\").to_numpy(dtype=float)\n",
    "    med  = np.nanmedian(vals)\n",
    "    mad  = np.nanmedian(np.abs(vals - med)) * 1.4826\n",
    "    if mad > 0:\n",
    "        return np.clip(vals, med - n_sigma * mad, med + n_sigma * mad)\n",
    "    else:\n",
    "        return np.clip(vals, 0, np.nanpercentile(vals, 95))\n",
    "\n",
    "def add_months_since_last_tx(dfc, df_month, id_col, suffix=\"\"):\n",
    "    \"\"\"Adds months_since_last_tx[suffix] to dfc.\"\"\"\n",
    "    col_name = f\"months_since_last_tx{suffix}\"\n",
    "    reference_date = df_month[\"month\"].max()\n",
    "    last_active = (\n",
    "        df_month[df_month[\"active_month\"] == 1]\n",
    "        .groupby(id_col)[\"month\"]\n",
    "        .max()\n",
    "        .reset_index(name=\"last_active_month\")\n",
    "    )\n",
    "    last_active[col_name] = (\n",
    "        (reference_date.to_period(\"M\") -\n",
    "         last_active[\"last_active_month\"].dt.to_period(\"M\"))\n",
    "        .apply(lambda x: x.n)\n",
    "    )\n",
    "    dfc = dfc.merge(last_active[[id_col, col_name]], on=id_col, how=\"left\")\n",
    "    max_months = dfc[col_name].max()\n",
    "    dfc[col_name] = dfc[col_name].fillna(max_months + 1)\n",
    "    return dfc\n",
    "\n",
    "\n",
    "def add_months_since_last_tx_by_group(df, id_cols, active_col=\"active_month\", month_col=\"month\", suffix=\"\"):\n",
    "    col_name = f\"months_since_last_tx{suffix}\"\n",
    "    reference_date = df[month_col].max()\n",
    "\n",
    "    last_active = (\n",
    "        df[df[active_col] == 1]\n",
    "        .groupby(id_cols)[month_col]\n",
    "        .max()\n",
    "        .reset_index(name=\"last_active_month\")\n",
    "    )\n",
    "\n",
    "    last_active[col_name] = (\n",
    "        (reference_date.to_period(\"M\") - last_active[\"last_active_month\"].dt.to_period(\"M\"))\n",
    "        .apply(lambda x: x.n)\n",
    "    )\n",
    "\n",
    "    return last_active[[*id_cols, col_name]]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "312153e6",
   "metadata": {},
   "source": [
    "---\n",
    "## 2. Data Loading\n",
    "\n",
    "Three data sources are used:\n",
    "- **AUM** (repaired): monthly share quantities per account and ISIN\n",
    "- **Flows**: daily net transactions, aggregated to monthly\n",
    "- **NAV / Rates**: fund performance and interest rate data for enrichment\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "011958df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "flows: (2514419, 25)\n",
      "aum:   (4824814, 19)\n",
      "nav:   (623914, 6)\n"
     ]
    }
   ],
   "source": [
    "PATH_FLOWS = \"s3://projet-bdc-data/carmignac/Flows ENSAE V2 -20251105.csv\"\n",
    "PATH_NAV = \"s3://projet-bdc-data/carmignac/Data Modélisation/Nav/NAV_Bench_data.csv\"\n",
    "PATH_RATES = \"s3://projet-bdc-data/carmignac/Data Modélisation/market data/esterRates.csv\"\n",
    "\n",
    "df_flows = pd.read_csv(PATH_FLOWS, sep=\";\")\n",
    "df_nav = pd.read_csv(PATH_NAV, sep=\";\")\n",
    "df_rates = pd.read_csv(PATH_RATES, sep=\";\")\n",
    "df_aum   = pd.read_csv(\"s3://projet-bdc-carmignac-g3/paco/AUM_repaired.csv\", low_memory=False) #all)\n",
    "\n",
    "\n",
    "# Date parsing\n",
    "for df, col in [\n",
    "    (df_flows, FLOW_DATE_COL), (df_aum, AUM_DATE_COL),\n",
    "    (df_nav,   NAV_DATE_COL),  (df_rates, RATE_DATE_COL)\n",
    "]:\n",
    "    df[col] = pd.to_datetime(df[col], errors=\"coerce\")\n",
    "    df[\"month\"] = df[col].dt.to_period(\"M\").dt.to_timestamp()\n",
    "\n",
    "for col in [FLOW_QTY_COL, FLOW_SUB_COL, FLOW_RED_COL]:\n",
    "    df_flows[col] = pd.to_numeric(df_flows[col], errors=\"coerce\")\n",
    "for col in [AUM_QTY_COL, AUM_VAL_COL]:\n",
    "    df_aum[col] = pd.to_numeric(df_aum[col], errors=\"coerce\")\n",
    "for col in [NAV_PRICE_COL, NAV_BENCH_COL]:\n",
    "    df_nav[col] = pd.to_numeric(df_nav[col], errors=\"coerce\")\n",
    "df_rates[RATE_VAL_COL] = pd.to_numeric(df_rates[RATE_VAL_COL], errors=\"coerce\")\n",
    "\n",
    "for df in [df_flows, df_aum]:\n",
    "    df[ISIN_COL] = df[ISIN_COL].astype(str).str.strip()\n",
    "df_nav[NAV_ISIN_COL] = df_nav[NAV_ISIN_COL].astype(str).str.strip()\n",
    "\n",
    "# Remove technical accounts (not investable)\n",
    "df_flows = df_flows[~df_flows[ID_COL].isin(\n",
    "    [\"Off Distribution\", \"Private Clients\", \"Private Client\"]\n",
    ")]\n",
    "df_aum = df_aum[~df_aum[ID_COL].isin(\n",
    "    [\"Off Distribution\", \"Private Clients\", \"Private Client\"]\n",
    ")]\n",
    "\n",
    "print(\"flows:\", df_flows.shape)\n",
    "print(\"aum:  \", df_aum.shape)\n",
    "print(\"nav:  \", df_nav.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cadf5a78-53f3-4157-878f-edc615ef1964",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Agreement - Code', 'Company - Id', 'Company - Ultimate Parent Id',\n",
       "       'Registrar Account - ID', 'Registrar Account - Region',\n",
       "       'RegistrarAccount - Country', 'Product - Asset Type',\n",
       "       'Product - Strategy', 'Product - Legal Status', 'Product - Is Dedie ?',\n",
       "       'Product - Fund', 'Product - Shareclass Type',\n",
       "       'Product - Shareclass Currency', 'Product - Isin',\n",
       "       'Centralisation Date', 'Quantity - Subscription',\n",
       "       'Quantity - Redemption', 'Quantity - NetFlows',\n",
       "       'Value Ccy - Subscription', 'Value Ccy - Redemption',\n",
       "       'Value Ccy - NetFlows', 'Value € - Subscription',\n",
       "       'Value € - Redemption', 'Value € - NetFlows', 'month'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_flows.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acd89acb-a9c1-4488-a47e-db4ca76b9214",
   "metadata": {},
   "source": [
    "## Fund Family Study - Fund ISIN and Name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f5c6782a-d1bb-478a-b8d0-9343e1071722",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "65"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_flows['Product - Fund'].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9eeabef2-636b-42ec-aa5a-3b3d80c5b0bc",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Carmignac Portfolio Investissement', 'Carmignac Patrimoine',\n",
       "       'Carmignac Investissement',\n",
       "       'Carmignac Portfolio Emerging Patrimoine',\n",
       "       'Carmignac Investissement Latitude', 'Carmignac Multi Expertise',\n",
       "       'Carmignac Portfolio Patrimoine Europe', 'Carmignac Credit 2027',\n",
       "       'Carmignac Emergents', 'Carmignac Portfolio Climate Transition',\n",
       "       'Carmignac Profil Réactif 100', 'Carmignac Absolute Return Europe',\n",
       "       'Carmignac Euro-Entrepreneurs', 'Carmignac Court Terme',\n",
       "       'Carmignac Portfolio Asia Discovery',\n",
       "       'Carmignac Portfolio Grande Europe', 'Carmignac Sécurité',\n",
       "       'Carmignac Portfolio Global Bond', 'Carmignac Portfolio Credit',\n",
       "       'Carmignac Portfolio Flexible Bond', 'Carmignac Profil Réactif 75',\n",
       "       'Carmignac Portfolio EM Debt',\n",
       "       'Carmignac Portfolio Euro-Entrepreneurs',\n",
       "       'Carmignac Portfolio Grandchildren',\n",
       "       'Carmignac Portfolio Investissement Latitude',\n",
       "       'Carmignac Portfolio Patrimoine', 'Carmignac Portfolio Sécurité',\n",
       "       'Carmignac Portfolio Long-Short European Equities',\n",
       "       'Carmignac Portfolio Emergents',\n",
       "       'Carmignac Portfolio Long-Short Global Equities',\n",
       "       'Carmignac Portfolio Inflation Solution', 'Carmignac Credit 2029',\n",
       "       'Carmignac Credit 2031', 'Carmignac Portfolio China New Economy',\n",
       "       'Carmignac Portfolio Capital Cube', 'Carmignac Credit 2025',\n",
       "       'Carmignac Portfolio Tech Solutions',\n",
       "       'Carmignac Epargne Actions Monde ISR',\n",
       "       'Carmignac China New Economy', 'Carmignac Portfolio China',\n",
       "       'Carmignac S.A. SICAV - PART II UCI Private Evergreen',\n",
       "       'Carmignac Portfolio Family Governed',\n",
       "       'Carmignac Alts ICAV Carmignac Credit Opportunities',\n",
       "       'Carmignac Portfolio Human Xperience',\n",
       "       'Carmignac Portfolio Merger Arbitrage Plus',\n",
       "       'Carmignac Portfolio Absolute Return Europe',\n",
       "       'FP Carmignac European Leaders',\n",
       "       'FP Carmignac Global Equity Compounders',\n",
       "       'FP Carmignac Emerging Markets', 'FP Carmignac Global Bond',\n",
       "       'Carmignac Portfolio Flexible Allocation 2024',\n",
       "       'Carmignac Portfolio Merger Arbitrage',\n",
       "       'Carmignac Portfolio Active Risk Allocation',\n",
       "       'Carmignac Alts ICAV European Long Short', 'Mapfre Carmignac F.P.',\n",
       "       'FP Carmignac Emerging Patrimoine', 'FP Carmignac Patrimoine',\n",
       "       'FP Carmignac Emerging Discovery',\n",
       "       'Credit Suisse Carmignac Emerging Markets Multi-Asset Fund',\n",
       "       'Fonditalia Carmignac Active Allocation',\n",
       "       'Carmignac Global Active', 'Solys - Carmignac Equity Selection',\n",
       "       'LUX IM - Carmignac Emerging Flexible Bond',\n",
       "       'Carmignac Portfolio Evolution', 'UFF Grande Europe 0-100'],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_flows['Product - Fund'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3d3012ac-5389-4fe5-9d96-1bca5ffd8985",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Agreement - Code', 'Company - Id', 'Company - Ultimate Parent Id',\n",
       "       'Registrar Account - ID', 'Registrar Account - Region',\n",
       "       'RegistrarAccount - Country', 'Product - Asset Type',\n",
       "       'Product - Strategy', 'Product - Legal Status', 'Product - Is Dedie ?',\n",
       "       'Product - Fund', 'Product - Shareclass Type',\n",
       "       'Product - Shareclass Currency', 'Product - Isin',\n",
       "       'Centralisation Date', 'Quantity - AUM', 'Value - AUM CCY',\n",
       "       'Value - AUM €', 'month'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_aum.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c505c481-3607-4589-afeb-9b6a58b8ecbc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "69"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_aum['Product - Fund'].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9e26280c-5e6f-40af-b86e-34f4440a024d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "387"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_aum['Product - Isin'].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "102e14d0-f90a-445d-9d12-f6fff2729b0d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(0)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_aum['Product - Fund'].isna().sum() #pas de nan "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "6f12be2c-e33e-4af6-b185-1b0a2794b9f5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nombre de couples uniques fund/isin : 387\n"
     ]
    },
    {
     "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 - Isin</th>\n",
       "      <th>Product - Fund</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>FR0011269166</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>FR0011269158</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>FR0011269406</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>FR0010149179</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>FR0011269547</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>FR001400JG56</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>IE00049IEN86</td>\n",
       "      <td>Carmignac Alts ICAV Carmignac Credit Opportuni...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>IE000L20NS05</td>\n",
       "      <td>Carmignac Alts ICAV Carmignac Credit Opportuni...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>IE000RU6SF09</td>\n",
       "      <td>Carmignac Alts ICAV European Long Short</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>FR0013467024</td>\n",
       "      <td>Carmignac China New Economy</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>FR001400R3Z5</td>\n",
       "      <td>Carmignac China New Economy</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>FR0014002E46</td>\n",
       "      <td>Carmignac China New Economy</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>FR0011269331</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>FR0010149161</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>FR0011269323</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>FR0000999999</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>FR0013516028</td>\n",
       "      <td>Carmignac Credit 2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>FR0013516002</td>\n",
       "      <td>Carmignac Credit 2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>FR0013516010</td>\n",
       "      <td>Carmignac Credit 2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>FR0013515970</td>\n",
       "      <td>Carmignac Credit 2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>FR0013515996</td>\n",
       "      <td>Carmignac Credit 2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>FR0013516036</td>\n",
       "      <td>Carmignac Credit 2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>FR0014008231</td>\n",
       "      <td>Carmignac Credit 2027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>FR0014008223</td>\n",
       "      <td>Carmignac Credit 2027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>FR00140081Z8</td>\n",
       "      <td>Carmignac Credit 2027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>FR0014008207</td>\n",
       "      <td>Carmignac Credit 2027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>FR0014008215</td>\n",
       "      <td>Carmignac Credit 2027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>FR00140081Y1</td>\n",
       "      <td>Carmignac Credit 2027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>FR001400M1O8</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>FR001400M1Q3</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>FR001400KAY8</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>FR001400KAX0</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>FR001400M1P5</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>FR001400KAW2</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>FR001400KAV4</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>FR001400M1N0</td>\n",
       "      <td>Carmignac Credit 2029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>FR001400U4X3</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>FR001400U4Y1</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>FR001400U4Z8</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>FR001400U4V7</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>FR001400U4T1</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>FR001400U4S3</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>FR001400U4W5</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>FR001400U4U9</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>FR001400XCT7</td>\n",
       "      <td>Carmignac Credit 2031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>FR0010956607</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>FR0011269372</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>FR0011269380</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>FR0011147446</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>FR0010149302</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>FR0011269349</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>FR0011269364</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>FR001400XC60</td>\n",
       "      <td>Carmignac Epargne Actions Monde ISR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>FR0010149112</td>\n",
       "      <td>Carmignac Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>FR0014000AL1</td>\n",
       "      <td>Carmignac Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>FR0010149278</td>\n",
       "      <td>Carmignac Euro-Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>FR00140051L1</td>\n",
       "      <td>Carmignac Global Active</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>FR0010149096</td>\n",
       "      <td>Carmignac Innovation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>FR0011269182</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>FR0011269554</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>FR0011269190</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>FR0010312660</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>FR0010956615</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>FR0011269570</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>FR0010148981</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>FR001400KIF0</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>FR001400U777</td>\n",
       "      <td>Carmignac Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>FR0010147603</td>\n",
       "      <td>Carmignac Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>FR0013527827</td>\n",
       "      <td>Carmignac Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>FR0010149203</td>\n",
       "      <td>Carmignac Multi Expertise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>FR0010956649</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>FR0011269588</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>FR0010135103</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>FR0011269067</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>FR0011269596</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>FR0010306142</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>FR0011443860</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>FR001400TXI4</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>FR0011443852</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>FR0011269075</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>LU2923680388</td>\n",
       "      <td>Carmignac Portfolio Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>LU1299301017</td>\n",
       "      <td>Carmignac Portfolio Active Risk Allocation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>LU0807689400</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>LU2427320572</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84</th>\n",
       "      <td>LU2427320499</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>85</th>\n",
       "      <td>LU0992630086</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>LU0553407650</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>LU0992629823</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>LU1623762256</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>LU2420651155</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>LU0807689582</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>LU0992629666</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>LU0992630169</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>LU2420651239</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>94</th>\n",
       "      <td>LU1623762330</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>LU0992629740</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>LU0336083810</td>\n",
       "      <td>Carmignac Portfolio Asia Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>LU1299307485</td>\n",
       "      <td>Carmignac Portfolio Capital Cube</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>LU1122113498</td>\n",
       "      <td>Carmignac Portfolio Capital Cube</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>LU1048598525</td>\n",
       "      <td>Carmignac Portfolio Capital Cube</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>LU1299308020</td>\n",
       "      <td>Carmignac Portfolio Capital Cube</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>LU1048598442</td>\n",
       "      <td>Carmignac Portfolio Capital Cube</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>LU1122072793</td>\n",
       "      <td>Carmignac Portfolio China</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>LU1122076430</td>\n",
       "      <td>Carmignac Portfolio China</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>LU2295992320</td>\n",
       "      <td>Carmignac Portfolio China New Economy</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105</th>\n",
       "      <td>LU2295992676</td>\n",
       "      <td>Carmignac Portfolio China New Economy</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>106</th>\n",
       "      <td>LU2427321117</td>\n",
       "      <td>Carmignac Portfolio China New Economy</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>107</th>\n",
       "      <td>LU1623762090</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>108</th>\n",
       "      <td>LU0553415323</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>109</th>\n",
       "      <td>LU0992629310</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>110</th>\n",
       "      <td>LU0164455502</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>111</th>\n",
       "      <td>LU0992629401</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>112</th>\n",
       "      <td>LU0992629583</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>113</th>\n",
       "      <td>LU0807690754</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>114</th>\n",
       "      <td>LU0705572823</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>LU0992629237</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>116</th>\n",
       "      <td>LU0807690671</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>117</th>\n",
       "      <td>LU0992629153</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>LU2772084310</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>LU1623762843</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>LU1623762926</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>LU2475941915</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>LU1932489690</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>LU2020612730</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>LU1623763064</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>LU2020612904</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>LU1623763148</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>LU2020612490</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>LU2020612813</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>LU2427321208</td>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>LU2638444914</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>LU1623763221</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>LU2427320903</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>LU2277146382</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>LU2346238343</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>LU2427320812</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>LU1623763734</td>\n",
       "      <td>Carmignac Portfolio EM Debt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>LU2420650777</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>LU0992627025</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>LU1299303575</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>LU1299303229</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>LU0992626720</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>LU0992626563</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>LU2420651072</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>LU1623762413</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>LU0992626647</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>LU0992626993</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>LU0992626480</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>LU1792391242</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>LU1299303062</td>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150</th>\n",
       "      <td>LU0807691059</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>151</th>\n",
       "      <td>LU0992631563</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>152</th>\n",
       "      <td>LU1792392059</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>153</th>\n",
       "      <td>LU0992631720</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>154</th>\n",
       "      <td>LU0992631993</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>155</th>\n",
       "      <td>LU0992632025</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>156</th>\n",
       "      <td>LU0592699259</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>157</th>\n",
       "      <td>LU0807690911</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>158</th>\n",
       "      <td>LU0592699093</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>159</th>\n",
       "      <td>LU0592698954</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>160</th>\n",
       "      <td>LU0807690838</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>161</th>\n",
       "      <td>LU0992631647</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162</th>\n",
       "      <td>LU0592699176</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>163</th>\n",
       "      <td>LU0992625755</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>164</th>\n",
       "      <td>LU1792392646</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>165</th>\n",
       "      <td>LU0992625672</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>166</th>\n",
       "      <td>LU1299303906</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167</th>\n",
       "      <td>LU1623762686</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168</th>\n",
       "      <td>LU1299304201</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169</th>\n",
       "      <td>LU0992625599</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>170</th>\n",
       "      <td>LU1299304540</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>171</th>\n",
       "      <td>LU0992625326</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>172</th>\n",
       "      <td>LU1299304896</td>\n",
       "      <td>Carmignac Portfolio Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>173</th>\n",
       "      <td>LU2534983825</td>\n",
       "      <td>Carmignac Portfolio Evolution</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>174</th>\n",
       "      <td>LU2462965026</td>\n",
       "      <td>Carmignac Portfolio Evolution</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>175</th>\n",
       "      <td>LU1966630706</td>\n",
       "      <td>Carmignac Portfolio Family Governed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>176</th>\n",
       "      <td>LU1966630961</td>\n",
       "      <td>Carmignac Portfolio Family Governed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>177</th>\n",
       "      <td>LU2004385154</td>\n",
       "      <td>Carmignac Portfolio Family Governed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>178</th>\n",
       "      <td>LU1873147984</td>\n",
       "      <td>Carmignac Portfolio Flexible Allocation 2024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>179</th>\n",
       "      <td>LU1873148016</td>\n",
       "      <td>Carmignac Portfolio Flexible Allocation 2024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>180</th>\n",
       "      <td>LU0807689749</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>181</th>\n",
       "      <td>LU0992631050</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182</th>\n",
       "      <td>LU2490324501</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>183</th>\n",
       "      <td>LU0336084032</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>184</th>\n",
       "      <td>LU2490324410</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>185</th>\n",
       "      <td>LU0992631480</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>186</th>\n",
       "      <td>LU1299302684</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>187</th>\n",
       "      <td>LU2490324337</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>188</th>\n",
       "      <td>LU2427321547</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>189</th>\n",
       "      <td>LU3060210526</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>190</th>\n",
       "      <td>LU0807689665</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>191</th>\n",
       "      <td>LU0992631308</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>192</th>\n",
       "      <td>LU0992631217</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>193</th>\n",
       "      <td>LU0553411090</td>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194</th>\n",
       "      <td>LU0807690085</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195</th>\n",
       "      <td>LU0992630243</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196</th>\n",
       "      <td>LU0992630599</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>LU0553413385</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>198</th>\n",
       "      <td>LU0992630755</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>199</th>\n",
       "      <td>LU0992630326</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>200</th>\n",
       "      <td>LU1792392307</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>201</th>\n",
       "      <td>LU1299302254</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>202</th>\n",
       "      <td>LU0992630839</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>203</th>\n",
       "      <td>LU0992630912</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204</th>\n",
       "      <td>LU1792392216</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>205</th>\n",
       "      <td>LU0807689822</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>206</th>\n",
       "      <td>LU0807690242</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>207</th>\n",
       "      <td>LU2420652047</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>208</th>\n",
       "      <td>LU2420651825</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>209</th>\n",
       "      <td>LU2278973172</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>210</th>\n",
       "      <td>LU1299301876</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211</th>\n",
       "      <td>LU0807690168</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212</th>\n",
       "      <td>LU1299302098</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>213</th>\n",
       "      <td>LU1748451231</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>214</th>\n",
       "      <td>LU1623762769</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>215</th>\n",
       "      <td>LU0336083497</td>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>216</th>\n",
       "      <td>LU1966631266</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>217</th>\n",
       "      <td>LU2004385667</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>218</th>\n",
       "      <td>LU2427320739</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>219</th>\n",
       "      <td>LU1966631001</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>220</th>\n",
       "      <td>LU2782951763</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>221</th>\n",
       "      <td>LU2420652476</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>222</th>\n",
       "      <td>LU2420652393</td>\n",
       "      <td>Carmignac Portfolio Grandchildren</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>223</th>\n",
       "      <td>LU0553405878</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>224</th>\n",
       "      <td>LU2420652989</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>225</th>\n",
       "      <td>LU0807689079</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>226</th>\n",
       "      <td>LU1792392729</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>227</th>\n",
       "      <td>LU0807689152</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>228</th>\n",
       "      <td>LU2420652807</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>229</th>\n",
       "      <td>LU2206982626</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>230</th>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>231</th>\n",
       "      <td>LU0992628932</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>232</th>\n",
       "      <td>LU2212178615</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>233</th>\n",
       "      <td>LU2420652633</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>LU0807688931</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>235</th>\n",
       "      <td>LU1623761951</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>LU2139905785</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>LU0807689236</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>LU1299301280</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>239</th>\n",
       "      <td>LU0992628775</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>240</th>\n",
       "      <td>LU0294249692</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>241</th>\n",
       "      <td>LU0992628858</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242</th>\n",
       "      <td>LU0992629070</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>243</th>\n",
       "      <td>LU2154448133</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>244</th>\n",
       "      <td>LU2295992163</td>\n",
       "      <td>Carmignac Portfolio Human Xperience</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>245</th>\n",
       "      <td>LU2295992247</td>\n",
       "      <td>Carmignac Portfolio Human Xperience</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>246</th>\n",
       "      <td>LU2947293564</td>\n",
       "      <td>Carmignac Portfolio Human Xperience</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>247</th>\n",
       "      <td>LU2601234839</td>\n",
       "      <td>Carmignac Portfolio Human Xperience</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>248</th>\n",
       "      <td>LU3088560464</td>\n",
       "      <td>Carmignac Portfolio Inflation Solution</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>249</th>\n",
       "      <td>LU2715954504</td>\n",
       "      <td>Carmignac Portfolio Inflation Solution</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>250</th>\n",
       "      <td>LU2715954330</td>\n",
       "      <td>Carmignac Portfolio Inflation Solution</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>251</th>\n",
       "      <td>LU0109929157</td>\n",
       "      <td>Carmignac Portfolio Infotech</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>252</th>\n",
       "      <td>LU0992626134</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>253</th>\n",
       "      <td>LU1299311321</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>254</th>\n",
       "      <td>LU0992626050</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>LU0992626217</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>256</th>\n",
       "      <td>LU0992625839</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>257</th>\n",
       "      <td>LU0992625912</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>258</th>\n",
       "      <td>LU1299311834</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>259</th>\n",
       "      <td>LU3149200746</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>260</th>\n",
       "      <td>LU1299311677</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>261</th>\n",
       "      <td>LU1299311164</td>\n",
       "      <td>Carmignac Portfolio Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>262</th>\n",
       "      <td>LU1046327349</td>\n",
       "      <td>Carmignac Portfolio Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>263</th>\n",
       "      <td>LU1046327000</td>\n",
       "      <td>Carmignac Portfolio Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>264</th>\n",
       "      <td>LU1046327182</td>\n",
       "      <td>Carmignac Portfolio Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>265</th>\n",
       "      <td>LU1046327422</td>\n",
       "      <td>Carmignac Portfolio Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>LU1317704051</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>LU1317704135</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>LU1317704218</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>LU0992627538</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>LU0992627371</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>271</th>\n",
       "      <td>LU1317704309</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>272</th>\n",
       "      <td>LU2914157503</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>273</th>\n",
       "      <td>LU0992627298</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>274</th>\n",
       "      <td>LU0992627454</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>275</th>\n",
       "      <td>LU3135111204</td>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>LU1910837415</td>\n",
       "      <td>Carmignac Portfolio Long-Short Global Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>277</th>\n",
       "      <td>LU2278971804</td>\n",
       "      <td>Carmignac Portfolio Long-Short Global Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>278</th>\n",
       "      <td>LU1910837258</td>\n",
       "      <td>Carmignac Portfolio Long-Short Global Equities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>LU0807690598</td>\n",
       "      <td>Carmignac Portfolio Market Neutral</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>280</th>\n",
       "      <td>LU0413372060</td>\n",
       "      <td>Carmignac Portfolio Market Neutral</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>LU0807690325</td>\n",
       "      <td>Carmignac Portfolio Market Neutral</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>282</th>\n",
       "      <td>LU0553414516</td>\n",
       "      <td>Carmignac Portfolio Market Neutral</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>283</th>\n",
       "      <td>LU2585800795</td>\n",
       "      <td>Carmignac Portfolio Merger Arbitrage</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>284</th>\n",
       "      <td>LU2585801173</td>\n",
       "      <td>Carmignac Portfolio Merger Arbitrage Plus</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>285</th>\n",
       "      <td>LU2585801256</td>\n",
       "      <td>Carmignac Portfolio Merger Arbitrage Plus</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>286</th>\n",
       "      <td>LU3016365556</td>\n",
       "      <td>Carmignac Portfolio Merger Arbitrage Plus</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>287</th>\n",
       "      <td>LU2585801330</td>\n",
       "      <td>Carmignac Portfolio Merger Arbitrage Plus</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>288</th>\n",
       "      <td>LU1163533695</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>289</th>\n",
       "      <td>LU0992627884</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>290</th>\n",
       "      <td>LU1163533851</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>291</th>\n",
       "      <td>LU0992627611</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>292</th>\n",
       "      <td>LU1792391754</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>LU1299305190</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>294</th>\n",
       "      <td>LU0992628692</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>LU0992627967</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>LU1792391671</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>297</th>\n",
       "      <td>LU0992628346</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>LU0992628429</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>LU1163533935</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300</th>\n",
       "      <td>LU1299305513</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>301</th>\n",
       "      <td>LU1792391838</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>302</th>\n",
       "      <td>LU1299305786</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>303</th>\n",
       "      <td>LU1299305356</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>304</th>\n",
       "      <td>LU1163533349</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>305</th>\n",
       "      <td>LU1299305943</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>306</th>\n",
       "      <td>LU0992628189</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>307</th>\n",
       "      <td>LU1163533422</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>308</th>\n",
       "      <td>LU1163533778</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>309</th>\n",
       "      <td>LU0992628007</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>310</th>\n",
       "      <td>LU0992627702</td>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>311</th>\n",
       "      <td>LU1744630424</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>312</th>\n",
       "      <td>LU2970252875</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>313</th>\n",
       "      <td>LU2181689576</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>314</th>\n",
       "      <td>LU2490324766</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>315</th>\n",
       "      <td>LU2369619742</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>316</th>\n",
       "      <td>LU2970252958</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>317</th>\n",
       "      <td>LU2490324683</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>318</th>\n",
       "      <td>LU1744628287</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>319</th>\n",
       "      <td>LU1932476879</td>\n",
       "      <td>Carmignac Portfolio Patrimoine Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>320</th>\n",
       "      <td>LU2420653367</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>321</th>\n",
       "      <td>LU2490324253</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322</th>\n",
       "      <td>LU0992625169</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>323</th>\n",
       "      <td>LU2426951195</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>324</th>\n",
       "      <td>LU0992625243</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>325</th>\n",
       "      <td>LU1299306321</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>326</th>\n",
       "      <td>LU1299306834</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>327</th>\n",
       "      <td>LU1299307055</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>328</th>\n",
       "      <td>LU0992624949</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>329</th>\n",
       "      <td>LU1299306677</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>330</th>\n",
       "      <td>LU1792391911</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>331</th>\n",
       "      <td>LU0992625086</td>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>332</th>\n",
       "      <td>LU2809794220</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>333</th>\n",
       "      <td>LU2809794493</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>334</th>\n",
       "      <td>LU2809794816</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>335</th>\n",
       "      <td>LU2812616816</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>336</th>\n",
       "      <td>LU2809794576</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>337</th>\n",
       "      <td>LU3060210443</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338</th>\n",
       "      <td>LU2809794733</td>\n",
       "      <td>Carmignac Portfolio Tech Solutions</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>339</th>\n",
       "      <td>FR0010149211</td>\n",
       "      <td>Carmignac Profil Réactif 100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>340</th>\n",
       "      <td>FR0010148999</td>\n",
       "      <td>Carmignac Profil Réactif 75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>341</th>\n",
       "      <td>LU2799473124</td>\n",
       "      <td>Carmignac S.A. SICAV - PART II UCI Private Eve...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>342</th>\n",
       "      <td>LU2799473397</td>\n",
       "      <td>Carmignac S.A. SICAV - PART II UCI Private Eve...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>FR0011269109</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>344</th>\n",
       "      <td>FR0011269125</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>345</th>\n",
       "      <td>FR0011269141</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>346</th>\n",
       "      <td>FR0011269083</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>347</th>\n",
       "      <td>FR0010149120</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>348</th>\n",
       "      <td>FR0011269091</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>349</th>\n",
       "      <td>LU1720511549</td>\n",
       "      <td>Credit Suisse Carmignac Emerging Markets Multi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>350</th>\n",
       "      <td>LU1720511895</td>\n",
       "      <td>Credit Suisse Carmignac Emerging Markets Multi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>351</th>\n",
       "      <td>LU1720513321</td>\n",
       "      <td>Credit Suisse Carmignac Emerging Markets Multi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>352</th>\n",
       "      <td>LU1720513677</td>\n",
       "      <td>Credit Suisse Carmignac Emerging Markets Multi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>353</th>\n",
       "      <td>LU1720515706</td>\n",
       "      <td>Credit Suisse Carmignac Emerging Markets Multi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>354</th>\n",
       "      <td>LU1720515615</td>\n",
       "      <td>Credit Suisse Carmignac Emerging Markets Multi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>355</th>\n",
       "      <td>GB00BJHPHX25</td>\n",
       "      <td>FP Carmignac Emerging Discovery</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>356</th>\n",
       "      <td>GB00BK1W2P36</td>\n",
       "      <td>FP Carmignac Emerging Markets</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>357</th>\n",
       "      <td>GB00BQXJRP97</td>\n",
       "      <td>FP Carmignac Emerging Markets</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>358</th>\n",
       "      <td>GB00BJHPHY32</td>\n",
       "      <td>FP Carmignac Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>359</th>\n",
       "      <td>GB00BJHPX895</td>\n",
       "      <td>FP Carmignac Emerging Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360</th>\n",
       "      <td>GB00BNDQ7P95</td>\n",
       "      <td>FP Carmignac European Leaders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>361</th>\n",
       "      <td>GB00BNDQ7N71</td>\n",
       "      <td>FP Carmignac European Leaders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>362</th>\n",
       "      <td>GB00BJHPXB21</td>\n",
       "      <td>FP Carmignac European Leaders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>363</th>\n",
       "      <td>GB00BJHPHZ49</td>\n",
       "      <td>FP Carmignac European Leaders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>364</th>\n",
       "      <td>GB00BRBXQT75</td>\n",
       "      <td>FP Carmignac Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>365</th>\n",
       "      <td>GB00BJHQ2K78</td>\n",
       "      <td>FP Carmignac Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>366</th>\n",
       "      <td>GB00BJHPZ502</td>\n",
       "      <td>FP Carmignac Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>367</th>\n",
       "      <td>GB00BJHQ2J63</td>\n",
       "      <td>FP Carmignac Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>368</th>\n",
       "      <td>GB00BJHPJ035</td>\n",
       "      <td>FP Carmignac Global Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>369</th>\n",
       "      <td>GB00BNDQ7Q03</td>\n",
       "      <td>FP Carmignac Global Equity Compounders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>370</th>\n",
       "      <td>GB00BMGLBL82</td>\n",
       "      <td>FP Carmignac Global Equity Compounders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>371</th>\n",
       "      <td>GB00BMGLBK75</td>\n",
       "      <td>FP Carmignac Global Equity Compounders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>372</th>\n",
       "      <td>GB00BMF9P332</td>\n",
       "      <td>FP Carmignac Global Equity Compounders</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>373</th>\n",
       "      <td>GB00BK1W2N12</td>\n",
       "      <td>FP Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>374</th>\n",
       "      <td>LU2251305400</td>\n",
       "      <td>Fonditalia Carmignac Active Allocation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>375</th>\n",
       "      <td>LU2251305319</td>\n",
       "      <td>Fonditalia Carmignac Active Allocation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>376</th>\n",
       "      <td>LU2251305236</td>\n",
       "      <td>Fonditalia Carmignac Active Allocation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>377</th>\n",
       "      <td>LU2250732448</td>\n",
       "      <td>Fonditalia Carmignac Active Allocation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>378</th>\n",
       "      <td>LU2250732281</td>\n",
       "      <td>Fonditalia Carmignac Active Allocation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>379</th>\n",
       "      <td>LU2721495427</td>\n",
       "      <td>LUX IM - Carmignac Emerging Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>380</th>\n",
       "      <td>LU2721494966</td>\n",
       "      <td>LUX IM - Carmignac Emerging Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>381</th>\n",
       "      <td>LU2721495005</td>\n",
       "      <td>LUX IM - Carmignac Emerging Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>382</th>\n",
       "      <td>LU2721495260</td>\n",
       "      <td>LUX IM - Carmignac Emerging Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>383</th>\n",
       "      <td>LU3124376941</td>\n",
       "      <td>LUX IM - Carmignac Emerging Flexible Bond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>384</th>\n",
       "      <td>MAPFRECG0001</td>\n",
       "      <td>Mapfre Carmignac F.P.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>385</th>\n",
       "      <td>LU2544562502</td>\n",
       "      <td>Solys - Carmignac Equity Selection</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>386</th>\n",
       "      <td>FR0011365873</td>\n",
       "      <td>UFF Grande Europe 0-100</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Product - Isin                                     Product - Fund\n",
       "0     FR0011269166                   Carmignac Absolute Return Europe\n",
       "1     FR0011269158                   Carmignac Absolute Return Europe\n",
       "2     FR0011269406                   Carmignac Absolute Return Europe\n",
       "3     FR0010149179                   Carmignac Absolute Return Europe\n",
       "4     FR0011269547                   Carmignac Absolute Return Europe\n",
       "5     FR001400JG56                   Carmignac Absolute Return Europe\n",
       "6     IE00049IEN86  Carmignac Alts ICAV Carmignac Credit Opportuni...\n",
       "7     IE000L20NS05  Carmignac Alts ICAV Carmignac Credit Opportuni...\n",
       "8     IE000RU6SF09            Carmignac Alts ICAV European Long Short\n",
       "9     FR0013467024                        Carmignac China New Economy\n",
       "10    FR001400R3Z5                        Carmignac China New Economy\n",
       "11    FR0014002E46                        Carmignac China New Economy\n",
       "12    FR0011269331                              Carmignac Court Terme\n",
       "13    FR0010149161                              Carmignac Court Terme\n",
       "14    FR0011269323                              Carmignac Court Terme\n",
       "15    FR0000999999                              Carmignac Court Terme\n",
       "16    FR0013516028                              Carmignac Credit 2025\n",
       "17    FR0013516002                              Carmignac Credit 2025\n",
       "18    FR0013516010                              Carmignac Credit 2025\n",
       "19    FR0013515970                              Carmignac Credit 2025\n",
       "20    FR0013515996                              Carmignac Credit 2025\n",
       "21    FR0013516036                              Carmignac Credit 2025\n",
       "22    FR0014008231                              Carmignac Credit 2027\n",
       "23    FR0014008223                              Carmignac Credit 2027\n",
       "24    FR00140081Z8                              Carmignac Credit 2027\n",
       "25    FR0014008207                              Carmignac Credit 2027\n",
       "26    FR0014008215                              Carmignac Credit 2027\n",
       "27    FR00140081Y1                              Carmignac Credit 2027\n",
       "28    FR001400M1O8                              Carmignac Credit 2029\n",
       "29    FR001400M1Q3                              Carmignac Credit 2029\n",
       "30    FR001400KAY8                              Carmignac Credit 2029\n",
       "31    FR001400KAX0                              Carmignac Credit 2029\n",
       "32    FR001400M1P5                              Carmignac Credit 2029\n",
       "33    FR001400KAW2                              Carmignac Credit 2029\n",
       "34    FR001400KAV4                              Carmignac Credit 2029\n",
       "35    FR001400M1N0                              Carmignac Credit 2029\n",
       "36    FR001400U4X3                              Carmignac Credit 2031\n",
       "37    FR001400U4Y1                              Carmignac Credit 2031\n",
       "38    FR001400U4Z8                              Carmignac Credit 2031\n",
       "39    FR001400U4V7                              Carmignac Credit 2031\n",
       "40    FR001400U4T1                              Carmignac Credit 2031\n",
       "41    FR001400U4S3                              Carmignac Credit 2031\n",
       "42    FR001400U4W5                              Carmignac Credit 2031\n",
       "43    FR001400U4U9                              Carmignac Credit 2031\n",
       "44    FR001400XCT7                              Carmignac Credit 2031\n",
       "45    FR0010956607                                Carmignac Emergents\n",
       "46    FR0011269372                                Carmignac Emergents\n",
       "47    FR0011269380                                Carmignac Emergents\n",
       "48    FR0011147446                                Carmignac Emergents\n",
       "49    FR0010149302                                Carmignac Emergents\n",
       "50    FR0011269349                                Carmignac Emergents\n",
       "51    FR0011269364                                Carmignac Emergents\n",
       "52    FR001400XC60                Carmignac Epargne Actions Monde ISR\n",
       "53    FR0010149112                       Carmignac Euro-Entrepreneurs\n",
       "54    FR0014000AL1                       Carmignac Euro-Entrepreneurs\n",
       "55    FR0010149278                      Carmignac Euro-Investissement\n",
       "56    FR00140051L1                            Carmignac Global Active\n",
       "57    FR0010149096                               Carmignac Innovation\n",
       "58    FR0011269182                           Carmignac Investissement\n",
       "59    FR0011269554                           Carmignac Investissement\n",
       "60    FR0011269190                           Carmignac Investissement\n",
       "61    FR0010312660                           Carmignac Investissement\n",
       "62    FR0010956615                           Carmignac Investissement\n",
       "63    FR0011269570                           Carmignac Investissement\n",
       "64    FR0010148981                           Carmignac Investissement\n",
       "65    FR001400KIF0                           Carmignac Investissement\n",
       "66    FR001400U777                  Carmignac Investissement Latitude\n",
       "67    FR0010147603                  Carmignac Investissement Latitude\n",
       "68    FR0013527827                  Carmignac Investissement Latitude\n",
       "69    FR0010149203                          Carmignac Multi Expertise\n",
       "70    FR0010956649                               Carmignac Patrimoine\n",
       "71    FR0011269588                               Carmignac Patrimoine\n",
       "72    FR0010135103                               Carmignac Patrimoine\n",
       "73    FR0011269067                               Carmignac Patrimoine\n",
       "74    FR0011269596                               Carmignac Patrimoine\n",
       "75    FR0010306142                               Carmignac Patrimoine\n",
       "76    FR0011443860                               Carmignac Patrimoine\n",
       "77    FR001400TXI4                               Carmignac Patrimoine\n",
       "78    FR0011443852                               Carmignac Patrimoine\n",
       "79    FR0011269075                               Carmignac Patrimoine\n",
       "80    LU2923680388         Carmignac Portfolio Absolute Return Europe\n",
       "81    LU1299301017         Carmignac Portfolio Active Risk Allocation\n",
       "82    LU0807689400                 Carmignac Portfolio Asia Discovery\n",
       "83    LU2427320572                 Carmignac Portfolio Asia Discovery\n",
       "84    LU2427320499                 Carmignac Portfolio Asia Discovery\n",
       "85    LU0992630086                 Carmignac Portfolio Asia Discovery\n",
       "86    LU0553407650                 Carmignac Portfolio Asia Discovery\n",
       "87    LU0992629823                 Carmignac Portfolio Asia Discovery\n",
       "88    LU1623762256                 Carmignac Portfolio Asia Discovery\n",
       "89    LU2420651155                 Carmignac Portfolio Asia Discovery\n",
       "90    LU0807689582                 Carmignac Portfolio Asia Discovery\n",
       "91    LU0992629666                 Carmignac Portfolio Asia Discovery\n",
       "92    LU0992630169                 Carmignac Portfolio Asia Discovery\n",
       "93    LU2420651239                 Carmignac Portfolio Asia Discovery\n",
       "94    LU1623762330                 Carmignac Portfolio Asia Discovery\n",
       "95    LU0992629740                 Carmignac Portfolio Asia Discovery\n",
       "96    LU0336083810                 Carmignac Portfolio Asia Discovery\n",
       "97    LU1299307485                   Carmignac Portfolio Capital Cube\n",
       "98    LU1122113498                   Carmignac Portfolio Capital Cube\n",
       "99    LU1048598525                   Carmignac Portfolio Capital Cube\n",
       "100   LU1299308020                   Carmignac Portfolio Capital Cube\n",
       "101   LU1048598442                   Carmignac Portfolio Capital Cube\n",
       "102   LU1122072793                          Carmignac Portfolio China\n",
       "103   LU1122076430                          Carmignac Portfolio China\n",
       "104   LU2295992320              Carmignac Portfolio China New Economy\n",
       "105   LU2295992676              Carmignac Portfolio China New Economy\n",
       "106   LU2427321117              Carmignac Portfolio China New Economy\n",
       "107   LU1623762090             Carmignac Portfolio Climate Transition\n",
       "108   LU0553415323             Carmignac Portfolio Climate Transition\n",
       "109   LU0992629310             Carmignac Portfolio Climate Transition\n",
       "110   LU0164455502             Carmignac Portfolio Climate Transition\n",
       "111   LU0992629401             Carmignac Portfolio Climate Transition\n",
       "112   LU0992629583             Carmignac Portfolio Climate Transition\n",
       "113   LU0807690754             Carmignac Portfolio Climate Transition\n",
       "114   LU0705572823             Carmignac Portfolio Climate Transition\n",
       "115   LU0992629237             Carmignac Portfolio Climate Transition\n",
       "116   LU0807690671             Carmignac Portfolio Climate Transition\n",
       "117   LU0992629153             Carmignac Portfolio Climate Transition\n",
       "118   LU2772084310                         Carmignac Portfolio Credit\n",
       "119   LU1623762843                         Carmignac Portfolio Credit\n",
       "120   LU1623762926                         Carmignac Portfolio Credit\n",
       "121   LU2475941915                         Carmignac Portfolio Credit\n",
       "122   LU1932489690                         Carmignac Portfolio Credit\n",
       "123   LU2020612730                         Carmignac Portfolio Credit\n",
       "124   LU1623763064                         Carmignac Portfolio Credit\n",
       "125   LU2020612904                         Carmignac Portfolio Credit\n",
       "126   LU1623763148                         Carmignac Portfolio Credit\n",
       "127   LU2020612490                         Carmignac Portfolio Credit\n",
       "128   LU2020612813                         Carmignac Portfolio Credit\n",
       "129   LU2427321208                         Carmignac Portfolio Credit\n",
       "130   LU2638444914                        Carmignac Portfolio EM Debt\n",
       "131   LU1623763221                        Carmignac Portfolio EM Debt\n",
       "132   LU2427320903                        Carmignac Portfolio EM Debt\n",
       "133   LU2277146382                        Carmignac Portfolio EM Debt\n",
       "134   LU2346238343                        Carmignac Portfolio EM Debt\n",
       "135   LU2427320812                        Carmignac Portfolio EM Debt\n",
       "136   LU1623763734                        Carmignac Portfolio EM Debt\n",
       "137   LU2420650777                      Carmignac Portfolio Emergents\n",
       "138   LU0992627025                      Carmignac Portfolio Emergents\n",
       "139   LU1299303575                      Carmignac Portfolio Emergents\n",
       "140   LU1299303229                      Carmignac Portfolio Emergents\n",
       "141   LU0992626720                      Carmignac Portfolio Emergents\n",
       "142   LU0992626563                      Carmignac Portfolio Emergents\n",
       "143   LU2420651072                      Carmignac Portfolio Emergents\n",
       "144   LU1623762413                      Carmignac Portfolio Emergents\n",
       "145   LU0992626647                      Carmignac Portfolio Emergents\n",
       "146   LU0992626993                      Carmignac Portfolio Emergents\n",
       "147   LU0992626480                      Carmignac Portfolio Emergents\n",
       "148   LU1792391242                      Carmignac Portfolio Emergents\n",
       "149   LU1299303062                      Carmignac Portfolio Emergents\n",
       "150   LU0807691059            Carmignac Portfolio Emerging Patrimoine\n",
       "151   LU0992631563            Carmignac Portfolio Emerging Patrimoine\n",
       "152   LU1792392059            Carmignac Portfolio Emerging Patrimoine\n",
       "153   LU0992631720            Carmignac Portfolio Emerging Patrimoine\n",
       "154   LU0992631993            Carmignac Portfolio Emerging Patrimoine\n",
       "155   LU0992632025            Carmignac Portfolio Emerging Patrimoine\n",
       "156   LU0592699259            Carmignac Portfolio Emerging Patrimoine\n",
       "157   LU0807690911            Carmignac Portfolio Emerging Patrimoine\n",
       "158   LU0592699093            Carmignac Portfolio Emerging Patrimoine\n",
       "159   LU0592698954            Carmignac Portfolio Emerging Patrimoine\n",
       "160   LU0807690838            Carmignac Portfolio Emerging Patrimoine\n",
       "161   LU0992631647            Carmignac Portfolio Emerging Patrimoine\n",
       "162   LU0592699176            Carmignac Portfolio Emerging Patrimoine\n",
       "163   LU0992625755             Carmignac Portfolio Euro-Entrepreneurs\n",
       "164   LU1792392646             Carmignac Portfolio Euro-Entrepreneurs\n",
       "165   LU0992625672             Carmignac Portfolio Euro-Entrepreneurs\n",
       "166   LU1299303906             Carmignac Portfolio Euro-Entrepreneurs\n",
       "167   LU1623762686             Carmignac Portfolio Euro-Entrepreneurs\n",
       "168   LU1299304201             Carmignac Portfolio Euro-Entrepreneurs\n",
       "169   LU0992625599             Carmignac Portfolio Euro-Entrepreneurs\n",
       "170   LU1299304540             Carmignac Portfolio Euro-Entrepreneurs\n",
       "171   LU0992625326             Carmignac Portfolio Euro-Entrepreneurs\n",
       "172   LU1299304896             Carmignac Portfolio Euro-Entrepreneurs\n",
       "173   LU2534983825                      Carmignac Portfolio Evolution\n",
       "174   LU2462965026                      Carmignac Portfolio Evolution\n",
       "175   LU1966630706                Carmignac Portfolio Family Governed\n",
       "176   LU1966630961                Carmignac Portfolio Family Governed\n",
       "177   LU2004385154                Carmignac Portfolio Family Governed\n",
       "178   LU1873147984       Carmignac Portfolio Flexible Allocation 2024\n",
       "179   LU1873148016       Carmignac Portfolio Flexible Allocation 2024\n",
       "180   LU0807689749                  Carmignac Portfolio Flexible Bond\n",
       "181   LU0992631050                  Carmignac Portfolio Flexible Bond\n",
       "182   LU2490324501                  Carmignac Portfolio Flexible Bond\n",
       "183   LU0336084032                  Carmignac Portfolio Flexible Bond\n",
       "184   LU2490324410                  Carmignac Portfolio Flexible Bond\n",
       "185   LU0992631480                  Carmignac Portfolio Flexible Bond\n",
       "186   LU1299302684                  Carmignac Portfolio Flexible Bond\n",
       "187   LU2490324337                  Carmignac Portfolio Flexible Bond\n",
       "188   LU2427321547                  Carmignac Portfolio Flexible Bond\n",
       "189   LU3060210526                  Carmignac Portfolio Flexible Bond\n",
       "190   LU0807689665                  Carmignac Portfolio Flexible Bond\n",
       "191   LU0992631308                  Carmignac Portfolio Flexible Bond\n",
       "192   LU0992631217                  Carmignac Portfolio Flexible Bond\n",
       "193   LU0553411090                  Carmignac Portfolio Flexible Bond\n",
       "194   LU0807690085                    Carmignac Portfolio Global Bond\n",
       "195   LU0992630243                    Carmignac Portfolio Global Bond\n",
       "196   LU0992630599                    Carmignac Portfolio Global Bond\n",
       "197   LU0553413385                    Carmignac Portfolio Global Bond\n",
       "198   LU0992630755                    Carmignac Portfolio Global Bond\n",
       "199   LU0992630326                    Carmignac Portfolio Global Bond\n",
       "200   LU1792392307                    Carmignac Portfolio Global Bond\n",
       "201   LU1299302254                    Carmignac Portfolio Global Bond\n",
       "202   LU0992630839                    Carmignac Portfolio Global Bond\n",
       "203   LU0992630912                    Carmignac Portfolio Global Bond\n",
       "204   LU1792392216                    Carmignac Portfolio Global Bond\n",
       "205   LU0807689822                    Carmignac Portfolio Global Bond\n",
       "206   LU0807690242                    Carmignac Portfolio Global Bond\n",
       "207   LU2420652047                    Carmignac Portfolio Global Bond\n",
       "208   LU2420651825                    Carmignac Portfolio Global Bond\n",
       "209   LU2278973172                    Carmignac Portfolio Global Bond\n",
       "210   LU1299301876                    Carmignac Portfolio Global Bond\n",
       "211   LU0807690168                    Carmignac Portfolio Global Bond\n",
       "212   LU1299302098                    Carmignac Portfolio Global Bond\n",
       "213   LU1748451231                    Carmignac Portfolio Global Bond\n",
       "214   LU1623762769                    Carmignac Portfolio Global Bond\n",
       "215   LU0336083497                    Carmignac Portfolio Global Bond\n",
       "216   LU1966631266                  Carmignac Portfolio Grandchildren\n",
       "217   LU2004385667                  Carmignac Portfolio Grandchildren\n",
       "218   LU2427320739                  Carmignac Portfolio Grandchildren\n",
       "219   LU1966631001                  Carmignac Portfolio Grandchildren\n",
       "220   LU2782951763                  Carmignac Portfolio Grandchildren\n",
       "221   LU2420652476                  Carmignac Portfolio Grandchildren\n",
       "222   LU2420652393                  Carmignac Portfolio Grandchildren\n",
       "223   LU0553405878                  Carmignac Portfolio Grande Europe\n",
       "224   LU2420652989                  Carmignac Portfolio Grande Europe\n",
       "225   LU0807689079                  Carmignac Portfolio Grande Europe\n",
       "226   LU1792392729                  Carmignac Portfolio Grande Europe\n",
       "227   LU0807689152                  Carmignac Portfolio Grande Europe\n",
       "228   LU2420652807                  Carmignac Portfolio Grande Europe\n",
       "229   LU2206982626                  Carmignac Portfolio Grande Europe\n",
       "230   LU0099161993                  Carmignac Portfolio Grande Europe\n",
       "231   LU0992628932                  Carmignac Portfolio Grande Europe\n",
       "232   LU2212178615                  Carmignac Portfolio Grande Europe\n",
       "233   LU2420652633                  Carmignac Portfolio Grande Europe\n",
       "234   LU0807688931                  Carmignac Portfolio Grande Europe\n",
       "235   LU1623761951                  Carmignac Portfolio Grande Europe\n",
       "236   LU2139905785                  Carmignac Portfolio Grande Europe\n",
       "237   LU0807689236                  Carmignac Portfolio Grande Europe\n",
       "238   LU1299301280                  Carmignac Portfolio Grande Europe\n",
       "239   LU0992628775                  Carmignac Portfolio Grande Europe\n",
       "240   LU0294249692                  Carmignac Portfolio Grande Europe\n",
       "241   LU0992628858                  Carmignac Portfolio Grande Europe\n",
       "242   LU0992629070                  Carmignac Portfolio Grande Europe\n",
       "243   LU2154448133                  Carmignac Portfolio Grande Europe\n",
       "244   LU2295992163                Carmignac Portfolio Human Xperience\n",
       "245   LU2295992247                Carmignac Portfolio Human Xperience\n",
       "246   LU2947293564                Carmignac Portfolio Human Xperience\n",
       "247   LU2601234839                Carmignac Portfolio Human Xperience\n",
       "248   LU3088560464             Carmignac Portfolio Inflation Solution\n",
       "249   LU2715954504             Carmignac Portfolio Inflation Solution\n",
       "250   LU2715954330             Carmignac Portfolio Inflation Solution\n",
       "251   LU0109929157                       Carmignac Portfolio Infotech\n",
       "252   LU0992626134                 Carmignac Portfolio Investissement\n",
       "253   LU1299311321                 Carmignac Portfolio Investissement\n",
       "254   LU0992626050                 Carmignac Portfolio Investissement\n",
       "255   LU0992626217                 Carmignac Portfolio Investissement\n",
       "256   LU0992625839                 Carmignac Portfolio Investissement\n",
       "257   LU0992625912                 Carmignac Portfolio Investissement\n",
       "258   LU1299311834                 Carmignac Portfolio Investissement\n",
       "259   LU3149200746                 Carmignac Portfolio Investissement\n",
       "260   LU1299311677                 Carmignac Portfolio Investissement\n",
       "261   LU1299311164                 Carmignac Portfolio Investissement\n",
       "262   LU1046327349        Carmignac Portfolio Investissement Latitude\n",
       "263   LU1046327000        Carmignac Portfolio Investissement Latitude\n",
       "264   LU1046327182        Carmignac Portfolio Investissement Latitude\n",
       "265   LU1046327422        Carmignac Portfolio Investissement Latitude\n",
       "266   LU1317704051   Carmignac Portfolio Long-Short European Equities\n",
       "267   LU1317704135   Carmignac Portfolio Long-Short European Equities\n",
       "268   LU1317704218   Carmignac Portfolio Long-Short European Equities\n",
       "269   LU0992627538   Carmignac Portfolio Long-Short European Equities\n",
       "270   LU0992627371   Carmignac Portfolio Long-Short European Equities\n",
       "271   LU1317704309   Carmignac Portfolio Long-Short European Equities\n",
       "272   LU2914157503   Carmignac Portfolio Long-Short European Equities\n",
       "273   LU0992627298   Carmignac Portfolio Long-Short European Equities\n",
       "274   LU0992627454   Carmignac Portfolio Long-Short European Equities\n",
       "275   LU3135111204   Carmignac Portfolio Long-Short European Equities\n",
       "276   LU1910837415     Carmignac Portfolio Long-Short Global Equities\n",
       "277   LU2278971804     Carmignac Portfolio Long-Short Global Equities\n",
       "278   LU1910837258     Carmignac Portfolio Long-Short Global Equities\n",
       "279   LU0807690598                 Carmignac Portfolio Market Neutral\n",
       "280   LU0413372060                 Carmignac Portfolio Market Neutral\n",
       "281   LU0807690325                 Carmignac Portfolio Market Neutral\n",
       "282   LU0553414516                 Carmignac Portfolio Market Neutral\n",
       "283   LU2585800795               Carmignac Portfolio Merger Arbitrage\n",
       "284   LU2585801173          Carmignac Portfolio Merger Arbitrage Plus\n",
       "285   LU2585801256          Carmignac Portfolio Merger Arbitrage Plus\n",
       "286   LU3016365556          Carmignac Portfolio Merger Arbitrage Plus\n",
       "287   LU2585801330          Carmignac Portfolio Merger Arbitrage Plus\n",
       "288   LU1163533695                     Carmignac Portfolio Patrimoine\n",
       "289   LU0992627884                     Carmignac Portfolio Patrimoine\n",
       "290   LU1163533851                     Carmignac Portfolio Patrimoine\n",
       "291   LU0992627611                     Carmignac Portfolio Patrimoine\n",
       "292   LU1792391754                     Carmignac Portfolio Patrimoine\n",
       "293   LU1299305190                     Carmignac Portfolio Patrimoine\n",
       "294   LU0992628692                     Carmignac Portfolio Patrimoine\n",
       "295   LU0992627967                     Carmignac Portfolio Patrimoine\n",
       "296   LU1792391671                     Carmignac Portfolio Patrimoine\n",
       "297   LU0992628346                     Carmignac Portfolio Patrimoine\n",
       "298   LU0992628429                     Carmignac Portfolio Patrimoine\n",
       "299   LU1163533935                     Carmignac Portfolio Patrimoine\n",
       "300   LU1299305513                     Carmignac Portfolio Patrimoine\n",
       "301   LU1792391838                     Carmignac Portfolio Patrimoine\n",
       "302   LU1299305786                     Carmignac Portfolio Patrimoine\n",
       "303   LU1299305356                     Carmignac Portfolio Patrimoine\n",
       "304   LU1163533349                     Carmignac Portfolio Patrimoine\n",
       "305   LU1299305943                     Carmignac Portfolio Patrimoine\n",
       "306   LU0992628189                     Carmignac Portfolio Patrimoine\n",
       "307   LU1163533422                     Carmignac Portfolio Patrimoine\n",
       "308   LU1163533778                     Carmignac Portfolio Patrimoine\n",
       "309   LU0992628007                     Carmignac Portfolio Patrimoine\n",
       "310   LU0992627702                     Carmignac Portfolio Patrimoine\n",
       "311   LU1744630424              Carmignac Portfolio Patrimoine Europe\n",
       "312   LU2970252875              Carmignac Portfolio Patrimoine Europe\n",
       "313   LU2181689576              Carmignac Portfolio Patrimoine Europe\n",
       "314   LU2490324766              Carmignac Portfolio Patrimoine Europe\n",
       "315   LU2369619742              Carmignac Portfolio Patrimoine Europe\n",
       "316   LU2970252958              Carmignac Portfolio Patrimoine Europe\n",
       "317   LU2490324683              Carmignac Portfolio Patrimoine Europe\n",
       "318   LU1744628287              Carmignac Portfolio Patrimoine Europe\n",
       "319   LU1932476879              Carmignac Portfolio Patrimoine Europe\n",
       "320   LU2420653367                       Carmignac Portfolio Sécurité\n",
       "321   LU2490324253                       Carmignac Portfolio Sécurité\n",
       "322   LU0992625169                       Carmignac Portfolio Sécurité\n",
       "323   LU2426951195                       Carmignac Portfolio Sécurité\n",
       "324   LU0992625243                       Carmignac Portfolio Sécurité\n",
       "325   LU1299306321                       Carmignac Portfolio Sécurité\n",
       "326   LU1299306834                       Carmignac Portfolio Sécurité\n",
       "327   LU1299307055                       Carmignac Portfolio Sécurité\n",
       "328   LU0992624949                       Carmignac Portfolio Sécurité\n",
       "329   LU1299306677                       Carmignac Portfolio Sécurité\n",
       "330   LU1792391911                       Carmignac Portfolio Sécurité\n",
       "331   LU0992625086                       Carmignac Portfolio Sécurité\n",
       "332   LU2809794220                 Carmignac Portfolio Tech Solutions\n",
       "333   LU2809794493                 Carmignac Portfolio Tech Solutions\n",
       "334   LU2809794816                 Carmignac Portfolio Tech Solutions\n",
       "335   LU2812616816                 Carmignac Portfolio Tech Solutions\n",
       "336   LU2809794576                 Carmignac Portfolio Tech Solutions\n",
       "337   LU3060210443                 Carmignac Portfolio Tech Solutions\n",
       "338   LU2809794733                 Carmignac Portfolio Tech Solutions\n",
       "339   FR0010149211                       Carmignac Profil Réactif 100\n",
       "340   FR0010148999                        Carmignac Profil Réactif 75\n",
       "341   LU2799473124  Carmignac S.A. SICAV - PART II UCI Private Eve...\n",
       "342   LU2799473397  Carmignac S.A. SICAV - PART II UCI Private Eve...\n",
       "343   FR0011269109                                 Carmignac Sécurité\n",
       "344   FR0011269125                                 Carmignac Sécurité\n",
       "345   FR0011269141                                 Carmignac Sécurité\n",
       "346   FR0011269083                                 Carmignac Sécurité\n",
       "347   FR0010149120                                 Carmignac Sécurité\n",
       "348   FR0011269091                                 Carmignac Sécurité\n",
       "349   LU1720511549  Credit Suisse Carmignac Emerging Markets Multi...\n",
       "350   LU1720511895  Credit Suisse Carmignac Emerging Markets Multi...\n",
       "351   LU1720513321  Credit Suisse Carmignac Emerging Markets Multi...\n",
       "352   LU1720513677  Credit Suisse Carmignac Emerging Markets Multi...\n",
       "353   LU1720515706  Credit Suisse Carmignac Emerging Markets Multi...\n",
       "354   LU1720515615  Credit Suisse Carmignac Emerging Markets Multi...\n",
       "355   GB00BJHPHX25                    FP Carmignac Emerging Discovery\n",
       "356   GB00BK1W2P36                      FP Carmignac Emerging Markets\n",
       "357   GB00BQXJRP97                      FP Carmignac Emerging Markets\n",
       "358   GB00BJHPHY32                   FP Carmignac Emerging Patrimoine\n",
       "359   GB00BJHPX895                   FP Carmignac Emerging Patrimoine\n",
       "360   GB00BNDQ7P95                      FP Carmignac European Leaders\n",
       "361   GB00BNDQ7N71                      FP Carmignac European Leaders\n",
       "362   GB00BJHPXB21                      FP Carmignac European Leaders\n",
       "363   GB00BJHPHZ49                      FP Carmignac European Leaders\n",
       "364   GB00BRBXQT75                           FP Carmignac Global Bond\n",
       "365   GB00BJHQ2K78                           FP Carmignac Global Bond\n",
       "366   GB00BJHPZ502                           FP Carmignac Global Bond\n",
       "367   GB00BJHQ2J63                           FP Carmignac Global Bond\n",
       "368   GB00BJHPJ035                           FP Carmignac Global Bond\n",
       "369   GB00BNDQ7Q03             FP Carmignac Global Equity Compounders\n",
       "370   GB00BMGLBL82             FP Carmignac Global Equity Compounders\n",
       "371   GB00BMGLBK75             FP Carmignac Global Equity Compounders\n",
       "372   GB00BMF9P332             FP Carmignac Global Equity Compounders\n",
       "373   GB00BK1W2N12                            FP Carmignac Patrimoine\n",
       "374   LU2251305400             Fonditalia Carmignac Active Allocation\n",
       "375   LU2251305319             Fonditalia Carmignac Active Allocation\n",
       "376   LU2251305236             Fonditalia Carmignac Active Allocation\n",
       "377   LU2250732448             Fonditalia Carmignac Active Allocation\n",
       "378   LU2250732281             Fonditalia Carmignac Active Allocation\n",
       "379   LU2721495427          LUX IM - Carmignac Emerging Flexible Bond\n",
       "380   LU2721494966          LUX IM - Carmignac Emerging Flexible Bond\n",
       "381   LU2721495005          LUX IM - Carmignac Emerging Flexible Bond\n",
       "382   LU2721495260          LUX IM - Carmignac Emerging Flexible Bond\n",
       "383   LU3124376941          LUX IM - Carmignac Emerging Flexible Bond\n",
       "384   MAPFRECG0001                              Mapfre Carmignac F.P.\n",
       "385   LU2544562502                 Solys - Carmignac Equity Selection\n",
       "386   FR0011365873                            UFF Grande Europe 0-100"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Tableau unique Fund Name + ISIN, trié par ISIN puis par nom de fonds\n",
    "pd.set_option(\"display.max_rows\", None)\n",
    "pd.set_option(\"display.max_columns\", None)\n",
    "\n",
    "fund_isin_table = (\n",
    "    df_aum[[\"Product - Isin\", \"Product - Fund\"]]\n",
    "    .dropna(subset=[\"Product - Isin\",\"Product - Fund\"])\n",
    "    .drop_duplicates()\n",
    "    .sort_values([\"Product - Fund\"])\n",
    "    .reset_index(drop=True)\n",
    ")\n",
    "\n",
    "print(f\"Nombre de couples uniques fund/isin : {fund_isin_table.shape[0]}\")\n",
    "fund_isin_table"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b568bbc3-55ad-4dcb-bdb0-94e9a154575d",
   "metadata": {},
   "source": [
    "---\n",
    "## 3. Part 0 — Define Family Funds & Select top 15 funds\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "70c8591f-29aa-4d2f-94bb-d3a280cbe5bb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nombre de couples ISIN/Fund : 387\n",
      "Nombre de funds uniques     : 69\n",
      "Nombre de families uniques  : 65\n"
     ]
    },
    {
     "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 - Isin</th>\n",
       "      <th>Product - Fund</th>\n",
       "      <th>fund_family</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>FR0000999999</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>FR0010135103</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>FR0010147603</td>\n",
       "      <td>Carmignac Investissement Latitude</td>\n",
       "      <td>Carmignac Investissement Latitude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>FR0010148981</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>FR0010148999</td>\n",
       "      <td>Carmignac Profil Réactif 75</td>\n",
       "      <td>Carmignac Profil Réactif &lt;NUM&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>FR0010149096</td>\n",
       "      <td>Carmignac Innovation</td>\n",
       "      <td>Carmignac Innovation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>FR0010149112</td>\n",
       "      <td>Carmignac Euro-Entrepreneurs</td>\n",
       "      <td>Carmignac Euro-Entrepreneurs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>FR0010149120</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>FR0010149161</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>FR0010149179</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "      <td>Carmignac Absolute Return Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>FR0010149203</td>\n",
       "      <td>Carmignac Multi Expertise</td>\n",
       "      <td>Carmignac Multi Expertise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>FR0010149211</td>\n",
       "      <td>Carmignac Profil Réactif 100</td>\n",
       "      <td>Carmignac Profil Réactif &lt;NUM&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>FR0010149278</td>\n",
       "      <td>Carmignac Euro-Investissement</td>\n",
       "      <td>Carmignac Euro-Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>FR0010149302</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>FR0010306142</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>FR0010312660</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>FR0010956607</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>FR0010956615</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "      <td>Carmignac Investissement</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>FR0010956649</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>FR0011147446</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Product - Isin                     Product - Fund  \\\n",
       "0    FR0000999999              Carmignac Court Terme   \n",
       "1    FR0010135103               Carmignac Patrimoine   \n",
       "2    FR0010147603  Carmignac Investissement Latitude   \n",
       "3    FR0010148981           Carmignac Investissement   \n",
       "4    FR0010148999        Carmignac Profil Réactif 75   \n",
       "5    FR0010149096               Carmignac Innovation   \n",
       "6    FR0010149112       Carmignac Euro-Entrepreneurs   \n",
       "7    FR0010149120                 Carmignac Sécurité   \n",
       "8    FR0010149161              Carmignac Court Terme   \n",
       "9    FR0010149179   Carmignac Absolute Return Europe   \n",
       "10   FR0010149203          Carmignac Multi Expertise   \n",
       "11   FR0010149211       Carmignac Profil Réactif 100   \n",
       "12   FR0010149278      Carmignac Euro-Investissement   \n",
       "13   FR0010149302                Carmignac Emergents   \n",
       "14   FR0010306142               Carmignac Patrimoine   \n",
       "15   FR0010312660           Carmignac Investissement   \n",
       "16   FR0010956607                Carmignac Emergents   \n",
       "17   FR0010956615           Carmignac Investissement   \n",
       "18   FR0010956649               Carmignac Patrimoine   \n",
       "19   FR0011147446                Carmignac Emergents   \n",
       "\n",
       "                          fund_family  \n",
       "0               Carmignac Court Terme  \n",
       "1                Carmignac Patrimoine  \n",
       "2   Carmignac Investissement Latitude  \n",
       "3            Carmignac Investissement  \n",
       "4      Carmignac Profil Réactif <NUM>  \n",
       "5                Carmignac Innovation  \n",
       "6        Carmignac Euro-Entrepreneurs  \n",
       "7                  Carmignac Sécurité  \n",
       "8               Carmignac Court Terme  \n",
       "9    Carmignac Absolute Return Europe  \n",
       "10          Carmignac Multi Expertise  \n",
       "11     Carmignac Profil Réactif <NUM>  \n",
       "12      Carmignac Euro-Investissement  \n",
       "13                Carmignac Emergents  \n",
       "14               Carmignac Patrimoine  \n",
       "15           Carmignac Investissement  \n",
       "16                Carmignac Emergents  \n",
       "17           Carmignac Investissement  \n",
       "18               Carmignac Patrimoine  \n",
       "19                Carmignac Emergents  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import re\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "# =========================================================\n",
    "# 1) Fonction conservative de construction de famille\n",
    "#    - même nom => même famille\n",
    "#    - différence purement numérique => même famille\n",
    "#    - sinon famille différente\n",
    "# =========================================================\n",
    "\n",
    "\n",
    "def build_fund_family_numeric_only(fund_name):\n",
    "    if pd.isna(fund_name):               # si le nom du fund est manquant\n",
    "        return np.nan                    # on retourne NaN\n",
    "    \n",
    "    s = str(fund_name).strip()           # transforme en string + enlève espaces début/fin\n",
    "    \n",
    "    family = re.sub(r\"\\d+\", \"<NUM>\", s)  # remplace tous les nombres par \"<NUM>\"\n",
    "    # ex: \"Credit 2027\" -> \"Credit <NUM>\"\n",
    "    \n",
    "    family = re.sub(r\"\\s+\", \" \", family).strip()  \n",
    "    # remplace espaces multiples par 1 seul + nettoie\n",
    "    \n",
    "    return family                        # retourne la famille construite\n",
    "\n",
    "fund_family_table = (\n",
    "    df_aum[[ISIN_COL, FUND_COL]]         # on garde seulement ISIN et nom du fund\n",
    "    .dropna(subset=[ISIN_COL, FUND_COL]) # enlève lignes avec valeurs manquantes\n",
    "    .drop_duplicates()                   # enlève doublons (même ISIN + fund)\n",
    "    .sort_values([ISIN_COL, FUND_COL])   # trie pour lisibilité\n",
    "    .reset_index(drop=True)              # reset index propre\n",
    ")\n",
    "\n",
    "fund_family_table[\"fund_family\"] = fund_family_table[FUND_COL].apply(build_fund_family_numeric_only)\n",
    "## applique la fonction à chaque nom de fund pour créer la colonne \"fund_family\"\n",
    "\n",
    "print(\"Nombre de couples ISIN/Fund :\", fund_family_table.shape[0])\n",
    "print(\"Nombre de funds uniques     :\", fund_family_table[FUND_COL].nunique())\n",
    "print(\"Nombre de families uniques  :\", fund_family_table[\"fund_family\"].nunique())\n",
    "\n",
    "fund_family_table.head(20)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d34f5ecf",
   "metadata": {},
   "source": [
    "---\n",
    "## 3. Monthly Panel Construction\n",
    "\n",
    "A full outer join of AUM and flows at `(account, ISIN, month)` granularity, enriched with NAV returns and interest rate changes.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "25f3dce4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "df_rel_m shape: (5184382, 20)\n"
     ]
    }
   ],
   "source": [
    "df_flows_m = (\n",
    "    df_flows\n",
    "    .dropna(subset=[ID_COL, ISIN_COL, \"month\"])\n",
    "    .assign(\n",
    "        gross_flow_qty=lambda x: x[FLOW_QTY_COL].abs(),\n",
    "        sub_qty=lambda x: x[FLOW_SUB_COL].fillna(0),\n",
    "        red_qty=lambda x: x[FLOW_RED_COL].fillna(0)\n",
    "    )\n",
    "    .groupby([ID_COL, ISIN_COL, \"month\"], as_index=False)\n",
    "    .agg(\n",
    "        net_flow_qty=(FLOW_QTY_COL, \"sum\"),\n",
    "        gross_flow_qty=(\"gross_flow_qty\", \"sum\"),\n",
    "        sub_qty=(\"sub_qty\", \"sum\"),\n",
    "        red_qty=(\"red_qty\", \"sum\"),\n",
    "        n_tx=(FLOW_QTY_COL, \"size\"),\n",
    "        region=(REGION_COL, \"last\"),\n",
    "        country=(COUNTRY_COL, \"last\")\n",
    "    )\n",
    ")\n",
    "\n",
    "df_aum_m = (\n",
    "    df_aum\n",
    "    .dropna(subset=[ID_COL, ISIN_COL, FUND_COL, \"month\"])\n",
    "    .groupby([ID_COL, ISIN_COL, FUND_COL, \"month\"], as_index=False)\n",
    "    .agg(\n",
    "        aum_qty=(AUM_QTY_COL, \"sum\"),\n",
    "        aum_val=(AUM_VAL_COL, \"sum\"),\n",
    "        asset_type=(ASSET_COL, \"last\"),\n",
    "        region=(REGION_COL, \"last\"),\n",
    "        country=(COUNTRY_COL, \"last\")\n",
    "    )\n",
    ")\n",
    "\n",
    "keys = pd.concat([\n",
    "    df_flows_m[[ID_COL, ISIN_COL, \"month\"]],\n",
    "    df_aum_m[[ID_COL, ISIN_COL, \"month\"]]\n",
    "]).drop_duplicates()\n",
    "\n",
    "df_rel_m = (\n",
    "    keys\n",
    "    .merge(df_aum_m, on=[ID_COL, ISIN_COL, \"month\"], how=\"left\")\n",
    "    .merge(df_flows_m, on=[ID_COL, ISIN_COL, \"month\"], how=\"left\", suffixes=(\"\", \"_flow\"))\n",
    ")\n",
    "\n",
    "for c in [\"aum_qty\", \"aum_val\", \"net_flow_qty\", \"gross_flow_qty\", \"sub_qty\", \"red_qty\", \"n_tx\"]:\n",
    "    df_rel_m[c] = df_rel_m[c].fillna(0)\n",
    "\n",
    "df_rel_m[\"region\"]  = df_rel_m[\"region\"].fillna(df_rel_m.get(\"region_flow\"))\n",
    "df_rel_m[\"country\"] = df_rel_m[\"country\"].fillna(df_rel_m.get(\"country_flow\"))\n",
    "\n",
    "df_rel_m[\"active_rel_month\"]  = (df_rel_m[\"gross_flow_qty\"] > 0).astype(int)\n",
    "df_rel_m[\"holding_rel_month\"] = (df_rel_m[\"aum_qty\"] > 0).astype(int)\n",
    "\n",
    "df_rel_m[\"flow_to_aum_rel\"] = np.where(\n",
    "    df_rel_m[\"aum_qty\"].abs() > 0,\n",
    "    df_rel_m[\"net_flow_qty\"] / df_rel_m[\"aum_qty\"].abs(),\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_rel_m[\"turnover_rel\"] = np.where(\n",
    "    df_rel_m[\"aum_qty\"].abs() > 0,\n",
    "    df_rel_m[\"gross_flow_qty\"] / df_rel_m[\"aum_qty\"].abs(),\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "print(\"df_rel_m shape:\", df_rel_m.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "0e95eaaa-3c49-44b9-b049-fee5ecba66ef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Panel with NAV/rates: (5184382, 22)\n"
     ]
    }
   ],
   "source": [
    "df_nav_m = (\n",
    "    df_nav\n",
    "    .dropna(subset=[NAV_ISIN_COL, \"month\", NAV_PRICE_COL])\n",
    "    .sort_values([NAV_ISIN_COL, \"month\"])\n",
    "    .groupby([NAV_ISIN_COL, \"month\"], as_index=False)\n",
    "    .tail(1)\n",
    ")\n",
    "\n",
    "df_nav_m[\"ret_fund_m\"] = df_nav_m.groupby(NAV_ISIN_COL)[NAV_PRICE_COL].pct_change()\n",
    "\n",
    "df_nav_m = df_nav_m.rename(columns={NAV_ISIN_COL: ISIN_COL})[\n",
    "    [ISIN_COL, \"month\", \"ret_fund_m\"]\n",
    "]\n",
    "\n",
    "df_rates_m = (\n",
    "    df_rates\n",
    "    .dropna(subset=[\"month\", RATE_VAL_COL])\n",
    "    .sort_values(RATE_DATE_COL)\n",
    "    .groupby(\"month\", as_index=False)\n",
    "    .tail(1)\n",
    ")\n",
    "\n",
    "df_rates_m[\"delta_rate_m\"] = df_rates_m[RATE_VAL_COL].diff()\n",
    "df_rates_m = df_rates_m[[\"month\", \"delta_rate_m\"]]\n",
    "\n",
    "df_rel_m = df_rel_m.merge(df_nav_m, on=[ISIN_COL, \"month\"], how=\"left\")\n",
    "df_rel_m = df_rel_m.merge(df_rates_m, on=\"month\", how=\"left\")\n",
    "\n",
    "for c in [\"ret_fund_m\", \"delta_rate_m\"]:\n",
    "    df_rel_m[c] = df_rel_m[c].fillna(0)\n",
    "\n",
    "print(\"Panel with NAV/rates:\", df_rel_m.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3ab14e2d-4d0c-4598-af3b-78c10b162510",
   "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>Registrar Account - ID</th>\n",
       "      <th>Product - Isin</th>\n",
       "      <th>month</th>\n",
       "      <th>Product - Fund</th>\n",
       "      <th>aum_qty</th>\n",
       "      <th>aum_val</th>\n",
       "      <th>asset_type</th>\n",
       "      <th>region</th>\n",
       "      <th>country</th>\n",
       "      <th>net_flow_qty</th>\n",
       "      <th>gross_flow_qty</th>\n",
       "      <th>sub_qty</th>\n",
       "      <th>red_qty</th>\n",
       "      <th>n_tx</th>\n",
       "      <th>region_flow</th>\n",
       "      <th>country_flow</th>\n",
       "      <th>active_rel_month</th>\n",
       "      <th>holding_rel_month</th>\n",
       "      <th>flow_to_aum_rel</th>\n",
       "      <th>turnover_rel</th>\n",
       "      <th>ret_fund_m</th>\n",
       "      <th>delta_rate_m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5184380</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-07-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184381</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-08-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.003</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Registrar Account - ID Product - Isin      month  \\\n",
       "5184380                  88928   LU0099161993 2021-07-01   \n",
       "5184381                  88928   LU0099161993 2021-08-01   \n",
       "\n",
       "                            Product - Fund  aum_qty  aum_val asset_type  \\\n",
       "5184380  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184381  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "\n",
       "             region     country  net_flow_qty  gross_flow_qty  sub_qty  \\\n",
       "5184380  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184381  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "\n",
       "         red_qty  n_tx region_flow country_flow  active_rel_month  \\\n",
       "5184380      0.0   0.0         NaN          NaN                 0   \n",
       "5184381      0.0   0.0         NaN          NaN                 0   \n",
       "\n",
       "         holding_rel_month  flow_to_aum_rel  turnover_rel  ret_fund_m  \\\n",
       "5184380                  0              NaN           NaN         0.0   \n",
       "5184381                  0              NaN           NaN         0.0   \n",
       "\n",
       "         delta_rate_m  \n",
       "5184380        -0.001  \n",
       "5184381        -0.003  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_rel_m.tail(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "bcefe148-dd84-476d-a960-52fabe5d92a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(527529)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_rel_m[FUND_COL].isna().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ec5783a8-4f47-42ff-a8d3-7276e355a34d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5184382, 22)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_rel_m.shape "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f4c2a3fd-2595-445b-95f5-bd544355e23d",
   "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>Registrar Account - ID</th>\n",
       "      <th>Product - Isin</th>\n",
       "      <th>month</th>\n",
       "      <th>Product - Fund</th>\n",
       "      <th>aum_qty</th>\n",
       "      <th>aum_val</th>\n",
       "      <th>asset_type</th>\n",
       "      <th>region</th>\n",
       "      <th>country</th>\n",
       "      <th>net_flow_qty</th>\n",
       "      <th>gross_flow_qty</th>\n",
       "      <th>sub_qty</th>\n",
       "      <th>red_qty</th>\n",
       "      <th>n_tx</th>\n",
       "      <th>region_flow</th>\n",
       "      <th>country_flow</th>\n",
       "      <th>active_rel_month</th>\n",
       "      <th>holding_rel_month</th>\n",
       "      <th>flow_to_aum_rel</th>\n",
       "      <th>turnover_rel</th>\n",
       "      <th>ret_fund_m</th>\n",
       "      <th>delta_rate_m</th>\n",
       "      <th>fund_family</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5184372</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2020-11-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.004</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184373</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2020-12-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.004</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184374</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-01-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.007</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184375</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-02-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184376</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-03-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.003</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184377</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-04-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184378</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-05-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184379</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-06-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184380</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-07-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.001</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5184381</th>\n",
       "      <td>88928</td>\n",
       "      <td>LU0099161993</td>\n",
       "      <td>2021-08-01</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Equity</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>Luxembourg</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.003</td>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Registrar Account - ID Product - Isin      month  \\\n",
       "5184372                  88928   LU0099161993 2020-11-01   \n",
       "5184373                  88928   LU0099161993 2020-12-01   \n",
       "5184374                  88928   LU0099161993 2021-01-01   \n",
       "5184375                  88928   LU0099161993 2021-02-01   \n",
       "5184376                  88928   LU0099161993 2021-03-01   \n",
       "5184377                  88928   LU0099161993 2021-04-01   \n",
       "5184378                  88928   LU0099161993 2021-05-01   \n",
       "5184379                  88928   LU0099161993 2021-06-01   \n",
       "5184380                  88928   LU0099161993 2021-07-01   \n",
       "5184381                  88928   LU0099161993 2021-08-01   \n",
       "\n",
       "                            Product - Fund  aum_qty  aum_val asset_type  \\\n",
       "5184372  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184373  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184374  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184375  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184376  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184377  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184378  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184379  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184380  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "5184381  Carmignac Portfolio Grande Europe      0.0      0.0     Equity   \n",
       "\n",
       "             region     country  net_flow_qty  gross_flow_qty  sub_qty  \\\n",
       "5184372  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184373  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184374  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184375  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184376  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184377  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184378  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184379  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184380  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "5184381  Luxembourg  Luxembourg           0.0             0.0      0.0   \n",
       "\n",
       "         red_qty  n_tx region_flow country_flow  active_rel_month  \\\n",
       "5184372      0.0   0.0         NaN          NaN                 0   \n",
       "5184373      0.0   0.0         NaN          NaN                 0   \n",
       "5184374      0.0   0.0         NaN          NaN                 0   \n",
       "5184375      0.0   0.0         NaN          NaN                 0   \n",
       "5184376      0.0   0.0         NaN          NaN                 0   \n",
       "5184377      0.0   0.0         NaN          NaN                 0   \n",
       "5184378      0.0   0.0         NaN          NaN                 0   \n",
       "5184379      0.0   0.0         NaN          NaN                 0   \n",
       "5184380      0.0   0.0         NaN          NaN                 0   \n",
       "5184381      0.0   0.0         NaN          NaN                 0   \n",
       "\n",
       "         holding_rel_month  flow_to_aum_rel  turnover_rel  ret_fund_m  \\\n",
       "5184372                  0              NaN           NaN         0.0   \n",
       "5184373                  0              NaN           NaN         0.0   \n",
       "5184374                  0              NaN           NaN         0.0   \n",
       "5184375                  0              NaN           NaN         0.0   \n",
       "5184376                  0              NaN           NaN         0.0   \n",
       "5184377                  0              NaN           NaN         0.0   \n",
       "5184378                  0              NaN           NaN         0.0   \n",
       "5184379                  0              NaN           NaN         0.0   \n",
       "5184380                  0              NaN           NaN         0.0   \n",
       "5184381                  0              NaN           NaN         0.0   \n",
       "\n",
       "         delta_rate_m                        fund_family  \n",
       "5184372        -0.004  Carmignac Portfolio Grande Europe  \n",
       "5184373         0.004  Carmignac Portfolio Grande Europe  \n",
       "5184374        -0.007  Carmignac Portfolio Grande Europe  \n",
       "5184375         0.001  Carmignac Portfolio Grande Europe  \n",
       "5184376        -0.003  Carmignac Portfolio Grande Europe  \n",
       "5184377         0.000  Carmignac Portfolio Grande Europe  \n",
       "5184378         0.000  Carmignac Portfolio Grande Europe  \n",
       "5184379         0.001  Carmignac Portfolio Grande Europe  \n",
       "5184380        -0.001  Carmignac Portfolio Grande Europe  \n",
       "5184381        -0.003  Carmignac Portfolio Grande Europe  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#merge famille\n",
    "df_rel_m = df_rel_m.merge(\n",
    "    fund_family_table[[ISIN_COL, FUND_COL, \"fund_family\"]],\n",
    "    on=[ISIN_COL, FUND_COL],\n",
    "    how=\"left\"\n",
    ")\n",
    "df_rel_m.tail(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f4fb4a9f-b354-42d0-8699-bf6fc1e26bb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "df_family_month shape: (3805010, 23)\n"
     ]
    },
    {
     "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>Registrar Account - ID</th>\n",
       "      <th>fund_family</th>\n",
       "      <th>month</th>\n",
       "      <th>aum_qty</th>\n",
       "      <th>aum_val</th>\n",
       "      <th>net_flow_qty</th>\n",
       "      <th>gross_flow_qty</th>\n",
       "      <th>sub_qty</th>\n",
       "      <th>red_qty</th>\n",
       "      <th>n_tx</th>\n",
       "      <th>n_isin_held</th>\n",
       "      <th>n_isin_active</th>\n",
       "      <th>ret_fund_m</th>\n",
       "      <th>delta_rate_m</th>\n",
       "      <th>region</th>\n",
       "      <th>country</th>\n",
       "      <th>active_month</th>\n",
       "      <th>flow_to_aum_m</th>\n",
       "      <th>turnover_m</th>\n",
       "      <th>sub_share_m</th>\n",
       "      <th>red_share_m</th>\n",
       "      <th>aum_peak_to_date</th>\n",
       "      <th>aum_drawdown</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.064516</td>\n",
       "      <td>-0.058</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-02-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.022</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-03-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.014</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-04-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.077</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-05-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.053</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-06-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.045455</td>\n",
       "      <td>0.020</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-07-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.042</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-08-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.008</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-09-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.012</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.007</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Registrar Account - ID                             fund_family      month  \\\n",
       "0              100000014  Carmignac Portfolio Climate Transition 2015-01-01   \n",
       "1              100000014  Carmignac Portfolio Climate Transition 2015-02-01   \n",
       "2              100000014  Carmignac Portfolio Climate Transition 2015-03-01   \n",
       "3              100000014  Carmignac Portfolio Climate Transition 2015-04-01   \n",
       "4              100000014  Carmignac Portfolio Climate Transition 2015-05-01   \n",
       "5              100000014  Carmignac Portfolio Climate Transition 2015-06-01   \n",
       "6              100000014  Carmignac Portfolio Climate Transition 2015-07-01   \n",
       "7              100000014  Carmignac Portfolio Climate Transition 2015-08-01   \n",
       "8              100000014  Carmignac Portfolio Climate Transition 2015-09-01   \n",
       "9              100000014  Carmignac Portfolio Climate Transition 2015-10-01   \n",
       "\n",
       "   aum_qty  aum_val  net_flow_qty  gross_flow_qty  sub_qty  red_qty  n_tx  \\\n",
       "0      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "1      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "2      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "3      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "4      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "5      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "6      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "7      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "8      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "9      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "\n",
       "   n_isin_held  n_isin_active  ret_fund_m  delta_rate_m       region  \\\n",
       "0            0              0    0.064516        -0.058  Switzerland   \n",
       "1            0              0    0.000000        -0.022  Switzerland   \n",
       "2            0              0    0.000000        -0.014  Switzerland   \n",
       "3            0              0    0.000000        -0.077  Switzerland   \n",
       "4            0              0    0.000000        -0.053  Switzerland   \n",
       "5            0              0    0.045455         0.020  Switzerland   \n",
       "6            0              0    0.000000        -0.042  Switzerland   \n",
       "7            0              0    0.000000        -0.008  Switzerland   \n",
       "8            0              0    0.000000        -0.012  Switzerland   \n",
       "9            0              0    0.000000        -0.007  Switzerland   \n",
       "\n",
       "       country  active_month  flow_to_aum_m  turnover_m  sub_share_m  \\\n",
       "0  Switzerland             0            NaN         NaN          NaN   \n",
       "1  Switzerland             0            NaN         NaN          NaN   \n",
       "2  Switzerland             0            NaN         NaN          NaN   \n",
       "3  Switzerland             0            NaN         NaN          NaN   \n",
       "4  Switzerland             0            NaN         NaN          NaN   \n",
       "5  Switzerland             0            NaN         NaN          NaN   \n",
       "6  Switzerland             0            NaN         NaN          NaN   \n",
       "7  Switzerland             0            NaN         NaN          NaN   \n",
       "8  Switzerland             0            NaN         NaN          NaN   \n",
       "9  Switzerland             0            NaN         NaN          NaN   \n",
       "\n",
       "   red_share_m  aum_peak_to_date  aum_drawdown  \n",
       "0          NaN               0.0           NaN  \n",
       "1          NaN               0.0           NaN  \n",
       "2          NaN               0.0           NaN  \n",
       "3          NaN               0.0           NaN  \n",
       "4          NaN               0.0           NaN  \n",
       "5          NaN               0.0           NaN  \n",
       "6          NaN               0.0           NaN  \n",
       "7          NaN               0.0           NaN  \n",
       "8          NaN               0.0           NaN  \n",
       "9          NaN               0.0           NaN  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#construction du panel mensuel compte × famille × mois \n",
    "tmp = df_rel_m.copy()\n",
    "tmp[\"isin_held_flag\"]   = (tmp[\"aum_qty\"] > 0).astype(int)\n",
    "tmp[\"isin_active_flag\"] = (tmp[\"gross_flow_qty\"] > 0).astype(int)\n",
    "\n",
    "df_family_month = (\n",
    "    tmp\n",
    "    .dropna(subset=[ID_COL, \"fund_family\", \"month\"])\n",
    "    .groupby([ID_COL, \"fund_family\", \"month\"], as_index=False) #groupesur family fund pas code isin\n",
    "    .agg(\n",
    "        aum_qty=(\"aum_qty\", \"sum\"), #somme sur les membres de la famille \n",
    "        aum_val=(\"aum_val\", \"sum\"),\n",
    "        net_flow_qty=(\"net_flow_qty\", \"sum\"),\n",
    "        gross_flow_qty=(\"gross_flow_qty\", \"sum\"),\n",
    "        sub_qty=(\"sub_qty\", \"sum\"),\n",
    "        red_qty=(\"red_qty\", \"sum\"),\n",
    "        n_tx=(\"n_tx\", \"sum\"),\n",
    "        n_isin_held=(\"isin_held_flag\", \"sum\"),\n",
    "        n_isin_active=(\"isin_active_flag\", \"sum\"),\n",
    "        ret_fund_m=(\"ret_fund_m\", \"mean\"),\n",
    "        delta_rate_m=(\"delta_rate_m\", \"first\"),\n",
    "        region=(\"region\", \"first\"),\n",
    "        country=(\"country\", \"first\")\n",
    "    )\n",
    "    .sort_values([ID_COL, \"fund_family\", \"month\"])\n",
    "    .reset_index(drop=True)\n",
    ")\n",
    "\n",
    "df_family_month[\"active_month\"] = (df_family_month[\"gross_flow_qty\"] > 0).astype(int)\n",
    "\n",
    "df_family_month[\"flow_to_aum_m\"] = np.where(\n",
    "    df_family_month[\"aum_qty\"].abs() > 0,\n",
    "    df_family_month[\"net_flow_qty\"] / df_family_month[\"aum_qty\"].abs(),\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_month[\"turnover_m\"] = np.where(\n",
    "    df_family_month[\"aum_qty\"].abs() > 0,\n",
    "    df_family_month[\"gross_flow_qty\"] / df_family_month[\"aum_qty\"].abs(),\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_month[\"sub_share_m\"] = np.where(\n",
    "    df_family_month[\"gross_flow_qty\"] > 0,\n",
    "    df_family_month[\"sub_qty\"] / df_family_month[\"gross_flow_qty\"],\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_month[\"red_share_m\"] = np.where(\n",
    "    df_family_month[\"gross_flow_qty\"] > 0,\n",
    "    df_family_month[\"red_qty\"] / df_family_month[\"gross_flow_qty\"],\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_month[\"aum_peak_to_date\"] = df_family_month.groupby([ID_COL, \"fund_family\"])[\"aum_qty\"].cummax()\n",
    "\n",
    "df_family_month[\"aum_drawdown\"] = np.where(\n",
    "    df_family_month[\"aum_peak_to_date\"] > 0,\n",
    "    1 - df_family_month[\"aum_qty\"] / df_family_month[\"aum_peak_to_date\"],\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "print(\"df_family_month shape:\", df_family_month.shape)\n",
    "df_family_month.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9121da21",
   "metadata": {},
   "source": [
    "---\n",
    "## 4. Feature Engineering\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "b7fdb2fe-26ce-4881-903d-01fd6e473ac4",
   "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>Registrar Account - ID</th>\n",
       "      <th>fund_family</th>\n",
       "      <th>month</th>\n",
       "      <th>aum_qty</th>\n",
       "      <th>aum_val</th>\n",
       "      <th>net_flow_qty</th>\n",
       "      <th>gross_flow_qty</th>\n",
       "      <th>sub_qty</th>\n",
       "      <th>red_qty</th>\n",
       "      <th>n_tx</th>\n",
       "      <th>n_isin_held</th>\n",
       "      <th>n_isin_active</th>\n",
       "      <th>ret_fund_m</th>\n",
       "      <th>delta_rate_m</th>\n",
       "      <th>region</th>\n",
       "      <th>country</th>\n",
       "      <th>active_month</th>\n",
       "      <th>flow_to_aum_m</th>\n",
       "      <th>turnover_m</th>\n",
       "      <th>sub_share_m</th>\n",
       "      <th>red_share_m</th>\n",
       "      <th>aum_peak_to_date</th>\n",
       "      <th>aum_drawdown</th>\n",
       "      <th>total_client_aum_qty</th>\n",
       "      <th>total_client_aum_val</th>\n",
       "      <th>family_share_of_client_aum</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.064516</td>\n",
       "      <td>-0.058</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-02-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.022</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-03-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.014</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-04-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.077</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-05-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.053</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-06-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.045455</td>\n",
       "      <td>0.020</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-07-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.042</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-08-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.008</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-09-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.012</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.007</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Registrar Account - ID                             fund_family      month  \\\n",
       "0              100000014  Carmignac Portfolio Climate Transition 2015-01-01   \n",
       "1              100000014  Carmignac Portfolio Climate Transition 2015-02-01   \n",
       "2              100000014  Carmignac Portfolio Climate Transition 2015-03-01   \n",
       "3              100000014  Carmignac Portfolio Climate Transition 2015-04-01   \n",
       "4              100000014  Carmignac Portfolio Climate Transition 2015-05-01   \n",
       "5              100000014  Carmignac Portfolio Climate Transition 2015-06-01   \n",
       "6              100000014  Carmignac Portfolio Climate Transition 2015-07-01   \n",
       "7              100000014  Carmignac Portfolio Climate Transition 2015-08-01   \n",
       "8              100000014  Carmignac Portfolio Climate Transition 2015-09-01   \n",
       "9              100000014  Carmignac Portfolio Climate Transition 2015-10-01   \n",
       "\n",
       "   aum_qty  aum_val  net_flow_qty  gross_flow_qty  sub_qty  red_qty  n_tx  \\\n",
       "0      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "1      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "2      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "3      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "4      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "5      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "6      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "7      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "8      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "9      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "\n",
       "   n_isin_held  n_isin_active  ret_fund_m  delta_rate_m       region  \\\n",
       "0            0              0    0.064516        -0.058  Switzerland   \n",
       "1            0              0    0.000000        -0.022  Switzerland   \n",
       "2            0              0    0.000000        -0.014  Switzerland   \n",
       "3            0              0    0.000000        -0.077  Switzerland   \n",
       "4            0              0    0.000000        -0.053  Switzerland   \n",
       "5            0              0    0.045455         0.020  Switzerland   \n",
       "6            0              0    0.000000        -0.042  Switzerland   \n",
       "7            0              0    0.000000        -0.008  Switzerland   \n",
       "8            0              0    0.000000        -0.012  Switzerland   \n",
       "9            0              0    0.000000        -0.007  Switzerland   \n",
       "\n",
       "       country  active_month  flow_to_aum_m  turnover_m  sub_share_m  \\\n",
       "0  Switzerland             0            NaN         NaN          NaN   \n",
       "1  Switzerland             0            NaN         NaN          NaN   \n",
       "2  Switzerland             0            NaN         NaN          NaN   \n",
       "3  Switzerland             0            NaN         NaN          NaN   \n",
       "4  Switzerland             0            NaN         NaN          NaN   \n",
       "5  Switzerland             0            NaN         NaN          NaN   \n",
       "6  Switzerland             0            NaN         NaN          NaN   \n",
       "7  Switzerland             0            NaN         NaN          NaN   \n",
       "8  Switzerland             0            NaN         NaN          NaN   \n",
       "9  Switzerland             0            NaN         NaN          NaN   \n",
       "\n",
       "   red_share_m  aum_peak_to_date  aum_drawdown  total_client_aum_qty  \\\n",
       "0          NaN               0.0           NaN                   0.0   \n",
       "1          NaN               0.0           NaN                   0.0   \n",
       "2          NaN               0.0           NaN                   0.0   \n",
       "3          NaN               0.0           NaN                   0.0   \n",
       "4          NaN               0.0           NaN                   0.0   \n",
       "5          NaN               0.0           NaN                   0.0   \n",
       "6          NaN               0.0           NaN                   0.0   \n",
       "7          NaN               0.0           NaN                   0.0   \n",
       "8          NaN               0.0           NaN                   0.0   \n",
       "9          NaN               0.0           NaN                   0.0   \n",
       "\n",
       "   total_client_aum_val  family_share_of_client_aum  \n",
       "0                   0.0                         NaN  \n",
       "1                   0.0                         NaN  \n",
       "2                   0.0                         NaN  \n",
       "3                   0.0                         NaN  \n",
       "4                   0.0                         NaN  \n",
       "5                   0.0                         NaN  \n",
       "6                   0.0                         NaN  \n",
       "7                   0.0                         NaN  \n",
       "8                   0.0                         NaN  \n",
       "9                   0.0                         NaN  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#On calcule : part du fund dans le portefeuille client\n",
    "\n",
    "df_client_total_month = ( #1 client tous les fonds\n",
    "    df_rel_m\n",
    "    .groupby([ID_COL, \"month\"], as_index=False) #client * mois\n",
    "    .agg(\n",
    "        total_client_aum_qty=(\"aum_qty\", \"sum\"),\n",
    "        total_client_aum_val=(\"aum_val\", \"sum\")\n",
    "    )\n",
    ")\n",
    "\n",
    "df_family_month = df_family_month.merge(\n",
    "    df_client_total_month,\n",
    "    on=[ID_COL, \"month\"],\n",
    "    how=\"left\"\n",
    ")\n",
    "\n",
    "df_family_month[\"family_share_of_client_aum\"] = np.where( #on cree la nouv colonnes \n",
    "    df_family_month[\"total_client_aum_val\"].abs() > 0,\n",
    "    df_family_month[\"aum_val\"] / df_family_month[\"total_client_aum_val\"].abs(),\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_month.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d4a01bcc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3805010, 44)\n"
     ]
    },
    {
     "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>Registrar Account - ID</th>\n",
       "      <th>fund_family</th>\n",
       "      <th>month</th>\n",
       "      <th>aum_qty</th>\n",
       "      <th>aum_val</th>\n",
       "      <th>net_flow_qty</th>\n",
       "      <th>gross_flow_qty</th>\n",
       "      <th>sub_qty</th>\n",
       "      <th>red_qty</th>\n",
       "      <th>n_tx</th>\n",
       "      <th>n_isin_held</th>\n",
       "      <th>n_isin_active</th>\n",
       "      <th>ret_fund_m</th>\n",
       "      <th>delta_rate_m</th>\n",
       "      <th>region</th>\n",
       "      <th>country</th>\n",
       "      <th>active_month</th>\n",
       "      <th>flow_to_aum_m</th>\n",
       "      <th>turnover_m</th>\n",
       "      <th>sub_share_m</th>\n",
       "      <th>red_share_m</th>\n",
       "      <th>aum_peak_to_date</th>\n",
       "      <th>aum_drawdown</th>\n",
       "      <th>total_client_aum_qty</th>\n",
       "      <th>total_client_aum_val</th>\n",
       "      <th>family_share_of_client_aum</th>\n",
       "      <th>prev_aum</th>\n",
       "      <th>entry_event</th>\n",
       "      <th>full_exit_event</th>\n",
       "      <th>ret_fund_m_lag1</th>\n",
       "      <th>buy_on_perf</th>\n",
       "      <th>sell_on_perf</th>\n",
       "      <th>ret_fund_mean3_lag1</th>\n",
       "      <th>ret_fund_mean6_lag1</th>\n",
       "      <th>buy_on_perf_mean3</th>\n",
       "      <th>sell_on_perf_mean3</th>\n",
       "      <th>buy_on_perf_mean6</th>\n",
       "      <th>sell_on_perf_mean6</th>\n",
       "      <th>turnover_m_mean3</th>\n",
       "      <th>flow_to_aum_m_mean3</th>\n",
       "      <th>turnover_m_mean6</th>\n",
       "      <th>flow_to_aum_m_mean6</th>\n",
       "      <th>turnover_m_mean12</th>\n",
       "      <th>flow_to_aum_m_mean12</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.064516</td>\n",
       "      <td>-0.058</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-02-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.022</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.064516</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.064516</td>\n",
       "      <td>0.064516</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-03-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.014</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.032258</td>\n",
       "      <td>0.032258</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-04-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.077</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.021505</td>\n",
       "      <td>0.021505</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-05-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.053</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.016129</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-06-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.045455</td>\n",
       "      <td>0.020</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.012903</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-07-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.042</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.045455</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.015152</td>\n",
       "      <td>0.018328</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-08-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.008</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.015152</td>\n",
       "      <td>0.007576</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-09-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.012</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.015152</td>\n",
       "      <td>0.007576</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.007</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.007576</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Registrar Account - ID                             fund_family      month  \\\n",
       "0              100000014  Carmignac Portfolio Climate Transition 2015-01-01   \n",
       "1              100000014  Carmignac Portfolio Climate Transition 2015-02-01   \n",
       "2              100000014  Carmignac Portfolio Climate Transition 2015-03-01   \n",
       "3              100000014  Carmignac Portfolio Climate Transition 2015-04-01   \n",
       "4              100000014  Carmignac Portfolio Climate Transition 2015-05-01   \n",
       "5              100000014  Carmignac Portfolio Climate Transition 2015-06-01   \n",
       "6              100000014  Carmignac Portfolio Climate Transition 2015-07-01   \n",
       "7              100000014  Carmignac Portfolio Climate Transition 2015-08-01   \n",
       "8              100000014  Carmignac Portfolio Climate Transition 2015-09-01   \n",
       "9              100000014  Carmignac Portfolio Climate Transition 2015-10-01   \n",
       "\n",
       "   aum_qty  aum_val  net_flow_qty  gross_flow_qty  sub_qty  red_qty  n_tx  \\\n",
       "0      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "1      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "2      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "3      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "4      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "5      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "6      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "7      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "8      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "9      0.0      0.0           0.0             0.0      0.0      0.0   0.0   \n",
       "\n",
       "   n_isin_held  n_isin_active  ret_fund_m  delta_rate_m       region  \\\n",
       "0            0              0    0.064516        -0.058  Switzerland   \n",
       "1            0              0    0.000000        -0.022  Switzerland   \n",
       "2            0              0    0.000000        -0.014  Switzerland   \n",
       "3            0              0    0.000000        -0.077  Switzerland   \n",
       "4            0              0    0.000000        -0.053  Switzerland   \n",
       "5            0              0    0.045455         0.020  Switzerland   \n",
       "6            0              0    0.000000        -0.042  Switzerland   \n",
       "7            0              0    0.000000        -0.008  Switzerland   \n",
       "8            0              0    0.000000        -0.012  Switzerland   \n",
       "9            0              0    0.000000        -0.007  Switzerland   \n",
       "\n",
       "       country  active_month  flow_to_aum_m  turnover_m  sub_share_m  \\\n",
       "0  Switzerland             0            NaN         NaN          NaN   \n",
       "1  Switzerland             0            NaN         NaN          NaN   \n",
       "2  Switzerland             0            NaN         NaN          NaN   \n",
       "3  Switzerland             0            NaN         NaN          NaN   \n",
       "4  Switzerland             0            NaN         NaN          NaN   \n",
       "5  Switzerland             0            NaN         NaN          NaN   \n",
       "6  Switzerland             0            NaN         NaN          NaN   \n",
       "7  Switzerland             0            NaN         NaN          NaN   \n",
       "8  Switzerland             0            NaN         NaN          NaN   \n",
       "9  Switzerland             0            NaN         NaN          NaN   \n",
       "\n",
       "   red_share_m  aum_peak_to_date  aum_drawdown  total_client_aum_qty  \\\n",
       "0          NaN               0.0           NaN                   0.0   \n",
       "1          NaN               0.0           NaN                   0.0   \n",
       "2          NaN               0.0           NaN                   0.0   \n",
       "3          NaN               0.0           NaN                   0.0   \n",
       "4          NaN               0.0           NaN                   0.0   \n",
       "5          NaN               0.0           NaN                   0.0   \n",
       "6          NaN               0.0           NaN                   0.0   \n",
       "7          NaN               0.0           NaN                   0.0   \n",
       "8          NaN               0.0           NaN                   0.0   \n",
       "9          NaN               0.0           NaN                   0.0   \n",
       "\n",
       "   total_client_aum_val  family_share_of_client_aum  prev_aum  entry_event  \\\n",
       "0                   0.0                         NaN       NaN            0   \n",
       "1                   0.0                         NaN       0.0            0   \n",
       "2                   0.0                         NaN       0.0            0   \n",
       "3                   0.0                         NaN       0.0            0   \n",
       "4                   0.0                         NaN       0.0            0   \n",
       "5                   0.0                         NaN       0.0            0   \n",
       "6                   0.0                         NaN       0.0            0   \n",
       "7                   0.0                         NaN       0.0            0   \n",
       "8                   0.0                         NaN       0.0            0   \n",
       "9                   0.0                         NaN       0.0            0   \n",
       "\n",
       "   full_exit_event  ret_fund_m_lag1  buy_on_perf  sell_on_perf  \\\n",
       "0                0              NaN            0             0   \n",
       "1                0         0.064516            0             0   \n",
       "2                0         0.000000            0             0   \n",
       "3                0         0.000000            0             0   \n",
       "4                0         0.000000            0             0   \n",
       "5                0         0.000000            0             0   \n",
       "6                0         0.045455            0             0   \n",
       "7                0         0.000000            0             0   \n",
       "8                0         0.000000            0             0   \n",
       "9                0         0.000000            0             0   \n",
       "\n",
       "   ret_fund_mean3_lag1  ret_fund_mean6_lag1  buy_on_perf_mean3  \\\n",
       "0                  NaN                  NaN                  0   \n",
       "1             0.064516             0.064516                  0   \n",
       "2             0.032258             0.032258                  0   \n",
       "3             0.021505             0.021505                  0   \n",
       "4             0.000000             0.016129                  0   \n",
       "5             0.000000             0.012903                  0   \n",
       "6             0.015152             0.018328                  0   \n",
       "7             0.015152             0.007576                  0   \n",
       "8             0.015152             0.007576                  0   \n",
       "9             0.000000             0.007576                  0   \n",
       "\n",
       "   sell_on_perf_mean3  buy_on_perf_mean6  sell_on_perf_mean6  \\\n",
       "0                   0                  0                   0   \n",
       "1                   0                  0                   0   \n",
       "2                   0                  0                   0   \n",
       "3                   0                  0                   0   \n",
       "4                   0                  0                   0   \n",
       "5                   0                  0                   0   \n",
       "6                   0                  0                   0   \n",
       "7                   0                  0                   0   \n",
       "8                   0                  0                   0   \n",
       "9                   0                  0                   0   \n",
       "\n",
       "   turnover_m_mean3  flow_to_aum_m_mean3  turnover_m_mean6  \\\n",
       "0               NaN                  NaN               NaN   \n",
       "1               NaN                  NaN               NaN   \n",
       "2               NaN                  NaN               NaN   \n",
       "3               NaN                  NaN               NaN   \n",
       "4               NaN                  NaN               NaN   \n",
       "5               NaN                  NaN               NaN   \n",
       "6               NaN                  NaN               NaN   \n",
       "7               NaN                  NaN               NaN   \n",
       "8               NaN                  NaN               NaN   \n",
       "9               NaN                  NaN               NaN   \n",
       "\n",
       "   flow_to_aum_m_mean6  turnover_m_mean12  flow_to_aum_m_mean12  \n",
       "0                  NaN                NaN                   NaN  \n",
       "1                  NaN                NaN                   NaN  \n",
       "2                  NaN                NaN                   NaN  \n",
       "3                  NaN                NaN                   NaN  \n",
       "4                  NaN                NaN                   NaN  \n",
       "5                  NaN                NaN                   NaN  \n",
       "6                  NaN                NaN                   NaN  \n",
       "7                  NaN                NaN                   NaN  \n",
       "8                  NaN                NaN                   NaN  \n",
       "9                  NaN                NaN                   NaN  "
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#feature engineering temporel au niveau client × famille × mois + comportement \n",
    "\n",
    "tmp = df_family_month.sort_values([ID_COL, \"fund_family\", \"month\"]).reset_index(drop=True)\n",
    "tmp[\"prev_aum\"] = tmp.groupby([ID_COL, \"fund_family\"])[\"aum_qty\"].shift(1)\n",
    "tmp[\"entry_event\"] = (\n",
    "    (tmp[\"prev_aum\"].fillna(0) <= 0) & (tmp[\"aum_qty\"] > 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"full_exit_event\"] = (\n",
    "    (tmp[\"prev_aum\"] > 0) & (tmp[\"aum_qty\"] <= 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"ret_fund_m_lag1\"] = tmp.groupby([ID_COL, \"fund_family\"])[\"ret_fund_m\"].shift(1)\n",
    "\n",
    "tmp[\"buy_on_perf\"] = (\n",
    "    (tmp[\"net_flow_qty\"] > 0) & (tmp[\"ret_fund_m_lag1\"] > 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"sell_on_perf\"] = (\n",
    "    (tmp[\"net_flow_qty\"] < 0) & (tmp[\"ret_fund_m_lag1\"] < 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"ret_fund_mean3_lag1\"] = (\n",
    "    tmp.groupby([ID_COL, \"fund_family\"])[\"ret_fund_m\"]\n",
    "       .transform(lambda s: s.shift(1).rolling(3, min_periods=1).mean())\n",
    ")\n",
    "\n",
    "tmp[\"ret_fund_mean6_lag1\"] = (\n",
    "    tmp.groupby([ID_COL, \"fund_family\"])[\"ret_fund_m\"]\n",
    "       .transform(lambda s: s.shift(1).rolling(6, min_periods=1).mean())\n",
    ")\n",
    "\n",
    "tmp[\"buy_on_perf_mean3\"] = (\n",
    "    (tmp[\"net_flow_qty\"] > 0) & (tmp[\"ret_fund_mean3_lag1\"] > 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"sell_on_perf_mean3\"] = (\n",
    "    (tmp[\"net_flow_qty\"] < 0) & (tmp[\"ret_fund_mean3_lag1\"] < 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"buy_on_perf_mean6\"] = (\n",
    "    (tmp[\"net_flow_qty\"] > 0) & (tmp[\"ret_fund_mean6_lag1\"] > 0)\n",
    ").astype(int)\n",
    "\n",
    "tmp[\"sell_on_perf_mean6\"] = (\n",
    "    (tmp[\"net_flow_qty\"] < 0) & (tmp[\"ret_fund_mean6_lag1\"] < 0)\n",
    ").astype(int)\n",
    "\n",
    "for w in [3, 6, 12]:\n",
    "    tmp[f\"turnover_m_mean{w}\"] = (\n",
    "        tmp.groupby([ID_COL, \"fund_family\"])[\"turnover_m\"]\n",
    "           .transform(lambda s: s.rolling(w, min_periods=1).mean())\n",
    "    )\n",
    "\n",
    "    tmp[f\"flow_to_aum_m_mean{w}\"] = (\n",
    "        tmp.groupby([ID_COL, \"fund_family\"])[\"flow_to_aum_m\"]\n",
    "           .transform(lambda s: s.rolling(w, min_periods=1).mean())\n",
    "    )\n",
    "\n",
    "print(tmp.shape)\n",
    "tmp.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "965cd530-9985-4d57-938c-cef531459c39",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "df_family_client_base shape: (53891, 49)\n"
     ]
    },
    {
     "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>Registrar Account - ID</th>\n",
       "      <th>fund_family</th>\n",
       "      <th>n_months</th>\n",
       "      <th>n_active_months</th>\n",
       "      <th>flow_freq</th>\n",
       "      <th>family_aum_qty_mean</th>\n",
       "      <th>family_aum_qty_median</th>\n",
       "      <th>family_aum_qty_max</th>\n",
       "      <th>family_aum_qty_last</th>\n",
       "      <th>family_aum_val_mean</th>\n",
       "      <th>family_aum_val_last</th>\n",
       "      <th>net_flow_qty_sum</th>\n",
       "      <th>gross_flow_qty_sum</th>\n",
       "      <th>gross_flow_qty_mean</th>\n",
       "      <th>sub_qty_sum</th>\n",
       "      <th>red_qty_sum</th>\n",
       "      <th>n_tx_total</th>\n",
       "      <th>avg_n_isin_held</th>\n",
       "      <th>max_n_isin_held</th>\n",
       "      <th>net_flow_qty_vol</th>\n",
       "      <th>flow_to_aum_mean</th>\n",
       "      <th>flow_to_aum_vol</th>\n",
       "      <th>turnover_mean</th>\n",
       "      <th>turnover_vol</th>\n",
       "      <th>sub_share_mean</th>\n",
       "      <th>red_share_mean</th>\n",
       "      <th>aum_drawdown_last</th>\n",
       "      <th>aum_drawdown_max</th>\n",
       "      <th>entry_count</th>\n",
       "      <th>full_exit_count</th>\n",
       "      <th>buy_on_perf_rate</th>\n",
       "      <th>sell_on_perf_rate</th>\n",
       "      <th>buy_on_perf_mean3_rate</th>\n",
       "      <th>sell_on_perf_mean3_rate</th>\n",
       "      <th>buy_on_perf_mean6_rate</th>\n",
       "      <th>sell_on_perf_mean6_rate</th>\n",
       "      <th>turnover_mean3_avg</th>\n",
       "      <th>turnover_mean6_avg</th>\n",
       "      <th>turnover_mean12_avg</th>\n",
       "      <th>flow_to_aum_mean3_avg</th>\n",
       "      <th>flow_to_aum_mean6_avg</th>\n",
       "      <th>flow_to_aum_mean12_avg</th>\n",
       "      <th>family_share_of_client_aum_mean</th>\n",
       "      <th>family_share_of_client_aum_max</th>\n",
       "      <th>ret_fund_m_mean</th>\n",
       "      <th>delta_rate_m_mean</th>\n",
       "      <th>region</th>\n",
       "      <th>country</th>\n",
       "      <th>months_since_last_tx_family</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.001500</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100000016</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000520</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100000016</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.002345</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100000028</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>80</td>\n",
       "      <td>2</td>\n",
       "      <td>0.025</td>\n",
       "      <td>9.529013</td>\n",
       "      <td>0.0</td>\n",
       "      <td>109.235</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1577.952730</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-109.238</td>\n",
       "      <td>109.238</td>\n",
       "      <td>1.365475</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-109.238</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.1000</td>\n",
       "      <td>1</td>\n",
       "      <td>10.559919</td>\n",
       "      <td>-0.021356</td>\n",
       "      <td>0.060405</td>\n",
       "      <td>0.021356</td>\n",
       "      <td>0.060405</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.019933</td>\n",
       "      <td>0.021247</td>\n",
       "      <td>0.021228</td>\n",
       "      <td>-0.019933</td>\n",
       "      <td>-0.021247</td>\n",
       "      <td>-0.021228</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.002345</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>121.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>100000038</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.003393</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>100000038</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.001500</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>100000038</td>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "      <td>56</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.005728</td>\n",
       "      <td>-0.004304</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>100000042</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>57.760063</td>\n",
       "      <td>0.0</td>\n",
       "      <td>660.115</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5579.536269</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0875</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.001500</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>100000044</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.001500</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>France</td>\n",
       "      <td>France</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>100000047</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.002345</td>\n",
       "      <td>-0.008925</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Registrar Account - ID                              fund_family  n_months  \\\n",
       "0              100000014   Carmignac Portfolio Climate Transition        80   \n",
       "1              100000016                      Carmignac Emergents        80   \n",
       "2              100000016                     Carmignac Patrimoine        80   \n",
       "3              100000028                     Carmignac Patrimoine        80   \n",
       "4              100000038                     Carmignac Patrimoine        80   \n",
       "5              100000038   Carmignac Portfolio Climate Transition        80   \n",
       "6              100000038  Carmignac Portfolio Emerging Patrimoine        56   \n",
       "7              100000042   Carmignac Portfolio Climate Transition        80   \n",
       "8              100000044   Carmignac Portfolio Climate Transition        80   \n",
       "9              100000047                     Carmignac Patrimoine        80   \n",
       "\n",
       "   n_active_months  flow_freq  family_aum_qty_mean  family_aum_qty_median  \\\n",
       "0                0      0.000             0.000000                    0.0   \n",
       "1                0      0.000             0.000000                    0.0   \n",
       "2                0      0.000             0.000000                    0.0   \n",
       "3                2      0.025             9.529013                    0.0   \n",
       "4                0      0.000             0.000000                    0.0   \n",
       "5                0      0.000             0.000000                    0.0   \n",
       "6                0      0.000             0.000000                    0.0   \n",
       "7                0      0.000            57.760063                    0.0   \n",
       "8                0      0.000             0.000000                    0.0   \n",
       "9                0      0.000             0.000000                    0.0   \n",
       "\n",
       "   family_aum_qty_max  family_aum_qty_last  family_aum_val_mean  \\\n",
       "0               0.000                  0.0             0.000000   \n",
       "1               0.000                  0.0             0.000000   \n",
       "2               0.000                  0.0             0.000000   \n",
       "3             109.235                  0.0          1577.952730   \n",
       "4               0.000                  0.0             0.000000   \n",
       "5               0.000                  0.0             0.000000   \n",
       "6               0.000                  0.0             0.000000   \n",
       "7             660.115                  0.0          5579.536269   \n",
       "8               0.000                  0.0             0.000000   \n",
       "9               0.000                  0.0             0.000000   \n",
       "\n",
       "   family_aum_val_last  net_flow_qty_sum  gross_flow_qty_sum  \\\n",
       "0                  0.0             0.000               0.000   \n",
       "1                  0.0             0.000               0.000   \n",
       "2                  0.0             0.000               0.000   \n",
       "3                  0.0          -109.238             109.238   \n",
       "4                  0.0             0.000               0.000   \n",
       "5                  0.0             0.000               0.000   \n",
       "6                  0.0             0.000               0.000   \n",
       "7                  0.0             0.000               0.000   \n",
       "8                  0.0             0.000               0.000   \n",
       "9                  0.0             0.000               0.000   \n",
       "\n",
       "   gross_flow_qty_mean  sub_qty_sum  red_qty_sum  n_tx_total  avg_n_isin_held  \\\n",
       "0             0.000000          0.0        0.000         0.0           0.0000   \n",
       "1             0.000000          0.0        0.000         0.0           0.0000   \n",
       "2             0.000000          0.0        0.000         0.0           0.0000   \n",
       "3             1.365475          0.0     -109.238         3.0           0.1000   \n",
       "4             0.000000          0.0        0.000         0.0           0.0000   \n",
       "5             0.000000          0.0        0.000         0.0           0.0000   \n",
       "6             0.000000          0.0        0.000         0.0           0.0000   \n",
       "7             0.000000          0.0        0.000         0.0           0.0875   \n",
       "8             0.000000          0.0        0.000         0.0           0.0000   \n",
       "9             0.000000          0.0        0.000         0.0           0.0000   \n",
       "\n",
       "   max_n_isin_held  net_flow_qty_vol  flow_to_aum_mean  flow_to_aum_vol  \\\n",
       "0                0          0.000000               NaN         0.000000   \n",
       "1                0          0.000000               NaN         0.000000   \n",
       "2                0          0.000000               NaN         0.000000   \n",
       "3                1         10.559919         -0.021356         0.060405   \n",
       "4                0          0.000000               NaN         0.000000   \n",
       "5                0          0.000000               NaN         0.000000   \n",
       "6                0          0.000000               NaN         0.000000   \n",
       "7                1          0.000000          0.000000         0.000000   \n",
       "8                0          0.000000               NaN         0.000000   \n",
       "9                0          0.000000               NaN         0.000000   \n",
       "\n",
       "   turnover_mean  turnover_vol  sub_share_mean  red_share_mean  \\\n",
       "0            NaN      0.000000             NaN             NaN   \n",
       "1            NaN      0.000000             NaN             NaN   \n",
       "2            NaN      0.000000             NaN             NaN   \n",
       "3       0.021356      0.060405             0.0            -1.0   \n",
       "4            NaN      0.000000             NaN             NaN   \n",
       "5            NaN      0.000000             NaN             NaN   \n",
       "6            NaN      0.000000             NaN             NaN   \n",
       "7       0.000000      0.000000             NaN             NaN   \n",
       "8            NaN      0.000000             NaN             NaN   \n",
       "9            NaN      0.000000             NaN             NaN   \n",
       "\n",
       "   aum_drawdown_last  aum_drawdown_max  entry_count  full_exit_count  \\\n",
       "0                NaN               NaN            0                0   \n",
       "1                NaN               NaN            0                0   \n",
       "2                NaN               NaN            0                0   \n",
       "3                1.0               1.0            1                1   \n",
       "4                NaN               NaN            0                0   \n",
       "5                NaN               NaN            0                0   \n",
       "6                NaN               NaN            0                0   \n",
       "7                1.0               1.0            1                1   \n",
       "8                NaN               NaN            0                0   \n",
       "9                NaN               NaN            0                0   \n",
       "\n",
       "   buy_on_perf_rate  sell_on_perf_rate  buy_on_perf_mean3_rate  \\\n",
       "0               0.0                0.0                     0.0   \n",
       "1               0.0                0.0                     0.0   \n",
       "2               0.0                0.0                     0.0   \n",
       "3               0.0                0.0                     0.0   \n",
       "4               0.0                0.0                     0.0   \n",
       "5               0.0                0.0                     0.0   \n",
       "6               0.0                0.0                     0.0   \n",
       "7               0.0                0.0                     0.0   \n",
       "8               0.0                0.0                     0.0   \n",
       "9               0.0                0.0                     0.0   \n",
       "\n",
       "   sell_on_perf_mean3_rate  buy_on_perf_mean6_rate  sell_on_perf_mean6_rate  \\\n",
       "0                      0.0                     0.0                      0.0   \n",
       "1                      0.0                     0.0                      0.0   \n",
       "2                      0.0                     0.0                      0.0   \n",
       "3                      0.0                     0.0                      0.0   \n",
       "4                      0.0                     0.0                      0.0   \n",
       "5                      0.0                     0.0                      0.0   \n",
       "6                      0.0                     0.0                      0.0   \n",
       "7                      0.0                     0.0                      0.0   \n",
       "8                      0.0                     0.0                      0.0   \n",
       "9                      0.0                     0.0                      0.0   \n",
       "\n",
       "   turnover_mean3_avg  turnover_mean6_avg  turnover_mean12_avg  \\\n",
       "0                 NaN                 NaN                  NaN   \n",
       "1                 NaN                 NaN                  NaN   \n",
       "2                 NaN                 NaN                  NaN   \n",
       "3            0.019933            0.021247             0.021228   \n",
       "4                 NaN                 NaN                  NaN   \n",
       "5                 NaN                 NaN                  NaN   \n",
       "6                 NaN                 NaN                  NaN   \n",
       "7            0.000000            0.000000             0.000000   \n",
       "8                 NaN                 NaN                  NaN   \n",
       "9                 NaN                 NaN                  NaN   \n",
       "\n",
       "   flow_to_aum_mean3_avg  flow_to_aum_mean6_avg  flow_to_aum_mean12_avg  \\\n",
       "0                    NaN                    NaN                     NaN   \n",
       "1                    NaN                    NaN                     NaN   \n",
       "2                    NaN                    NaN                     NaN   \n",
       "3              -0.019933              -0.021247               -0.021228   \n",
       "4                    NaN                    NaN                     NaN   \n",
       "5                    NaN                    NaN                     NaN   \n",
       "6                    NaN                    NaN                     NaN   \n",
       "7               0.000000               0.000000                0.000000   \n",
       "8                    NaN                    NaN                     NaN   \n",
       "9                    NaN                    NaN                     NaN   \n",
       "\n",
       "   family_share_of_client_aum_mean  family_share_of_client_aum_max  \\\n",
       "0                              NaN                             NaN   \n",
       "1                              NaN                             NaN   \n",
       "2                              NaN                             NaN   \n",
       "3                              1.0                             1.0   \n",
       "4                              NaN                             NaN   \n",
       "5                              NaN                             NaN   \n",
       "6                              NaN                             NaN   \n",
       "7                              1.0                             1.0   \n",
       "8                              NaN                             NaN   \n",
       "9                              NaN                             NaN   \n",
       "\n",
       "   ret_fund_m_mean  delta_rate_m_mean          region         country  \\\n",
       "0         0.001500          -0.008925     Switzerland     Switzerland   \n",
       "1         0.000520          -0.008925  United Kingdom  United Kingdom   \n",
       "2         0.002345          -0.008925  United Kingdom  United Kingdom   \n",
       "3         0.002345          -0.008925  United Kingdom  United Kingdom   \n",
       "4         0.003393          -0.008925     Switzerland     Switzerland   \n",
       "5         0.001500          -0.008925     Switzerland     Switzerland   \n",
       "6         0.005728          -0.004304     Switzerland     Switzerland   \n",
       "7         0.001500          -0.008925  United Kingdom  United Kingdom   \n",
       "8         0.001500          -0.008925          France          France   \n",
       "9         0.002345          -0.008925  United Kingdom  United Kingdom   \n",
       "\n",
       "   months_since_last_tx_family  \n",
       "0                          0.0  \n",
       "1                          0.0  \n",
       "2                          0.0  \n",
       "3                        121.0  \n",
       "4                          0.0  \n",
       "5                          0.0  \n",
       "6                          0.0  \n",
       "7                          0.0  \n",
       "8                          0.0  \n",
       "9                          0.0  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#table finale de features au niveau client × famille\n",
    "months_since_last_tx = add_months_since_last_tx_by_group(\n",
    "    tmp,\n",
    "    id_cols=[ID_COL, \"fund_family\"],\n",
    "    active_col=\"active_month\",\n",
    "    month_col=\"month\",\n",
    "    suffix=\"_family\"\n",
    ") #calcule, pour chaque couple : client*famille de fonds // combien de mois se sont écoulés depuis la dernière activité.\n",
    "\n",
    "df_family_client_base = ( #1client *1 fund family\n",
    "    tmp\n",
    "    .groupby([ID_COL, \"fund_family\"], as_index=False)\n",
    "    .agg(\n",
    "        n_months=(\"month\", \"nunique\"),\n",
    "        n_active_months=(\"active_month\", \"sum\"),\n",
    "        flow_freq=(\"active_month\", \"mean\"),\n",
    "\n",
    "        family_aum_qty_mean=(\"aum_qty\", \"mean\"),\n",
    "        family_aum_qty_median=(\"aum_qty\", \"median\"),\n",
    "        family_aum_qty_max=(\"aum_qty\", \"max\"),\n",
    "        family_aum_qty_last=(\"aum_qty\", \"last\"),\n",
    "\n",
    "        family_aum_val_mean=(\"aum_val\", \"mean\"),\n",
    "        family_aum_val_last=(\"aum_val\", \"last\"),\n",
    "\n",
    "        net_flow_qty_sum=(\"net_flow_qty\", \"sum\"),\n",
    "        gross_flow_qty_sum=(\"gross_flow_qty\", \"sum\"),\n",
    "        gross_flow_qty_mean=(\"gross_flow_qty\", \"mean\"),\n",
    "\n",
    "        sub_qty_sum=(\"sub_qty\", \"sum\"),\n",
    "        red_qty_sum=(\"red_qty\", \"sum\"),\n",
    "        n_tx_total=(\"n_tx\", \"sum\"),\n",
    "\n",
    "        avg_n_isin_held=(\"n_isin_held\", \"mean\"),\n",
    "        max_n_isin_held=(\"n_isin_held\", \"max\"),\n",
    "\n",
    "        net_flow_qty_vol=(\"net_flow_qty\", \"std\"),\n",
    "        flow_to_aum_mean=(\"flow_to_aum_m\", \"mean\"),\n",
    "        flow_to_aum_vol=(\"flow_to_aum_m\", \"std\"),\n",
    "        turnover_mean=(\"turnover_m\", \"mean\"),\n",
    "        turnover_vol=(\"turnover_m\", \"std\"),\n",
    "\n",
    "        sub_share_mean=(\"sub_share_m\", \"mean\"),\n",
    "        red_share_mean=(\"red_share_m\", \"mean\"),\n",
    "\n",
    "        aum_drawdown_last=(\"aum_drawdown\", \"last\"),\n",
    "        aum_drawdown_max=(\"aum_drawdown\", \"max\"),\n",
    "\n",
    "        entry_count=(\"entry_event\", \"sum\"),\n",
    "        full_exit_count=(\"full_exit_event\", \"sum\"),\n",
    "\n",
    "        buy_on_perf_rate=(\"buy_on_perf\", \"mean\"),\n",
    "        sell_on_perf_rate=(\"sell_on_perf\", \"mean\"),\n",
    "        buy_on_perf_mean3_rate=(\"buy_on_perf_mean3\", \"mean\"),\n",
    "        sell_on_perf_mean3_rate=(\"sell_on_perf_mean3\", \"mean\"),\n",
    "        buy_on_perf_mean6_rate=(\"buy_on_perf_mean6\", \"mean\"),\n",
    "        sell_on_perf_mean6_rate=(\"sell_on_perf_mean6\", \"mean\"),\n",
    "\n",
    "        turnover_mean3_avg=(\"turnover_m_mean3\", \"mean\"),\n",
    "        turnover_mean6_avg=(\"turnover_m_mean6\", \"mean\"),\n",
    "        turnover_mean12_avg=(\"turnover_m_mean12\", \"mean\"),\n",
    "\n",
    "        flow_to_aum_mean3_avg=(\"flow_to_aum_m_mean3\", \"mean\"),\n",
    "        flow_to_aum_mean6_avg=(\"flow_to_aum_m_mean6\", \"mean\"),\n",
    "        flow_to_aum_mean12_avg=(\"flow_to_aum_m_mean12\", \"mean\"),\n",
    "\n",
    "        family_share_of_client_aum_mean=(\"family_share_of_client_aum\", \"mean\"),\n",
    "        family_share_of_client_aum_max=(\"family_share_of_client_aum\", \"max\"),\n",
    "\n",
    "        ret_fund_m_mean=(\"ret_fund_m\", \"mean\"),\n",
    "        delta_rate_m_mean=(\"delta_rate_m\", \"mean\"),\n",
    "\n",
    "        region=(\"region\", \"last\"),\n",
    "        country=(\"country\", \"last\"),\n",
    "    )\n",
    "    .merge(months_since_last_tx, on=[ID_COL, \"fund_family\"], how=\"left\")\n",
    ")\n",
    "\n",
    "for col in [\n",
    "    \"net_flow_qty_vol\",\n",
    "    \"flow_to_aum_vol\",\n",
    "    \"turnover_vol\",\n",
    "    \"months_since_last_tx_family\"\n",
    "]:\n",
    "    if col in df_family_client_base.columns:\n",
    "        df_family_client_base[col] = df_family_client_base[col].fillna(0)\n",
    "\n",
    "print(\"df_family_client_base shape:\", df_family_client_base.shape)\n",
    "df_family_client_base.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac6b1959",
   "metadata": {},
   "source": [
    "---\n",
    "## 5. Part 1 — Top 15 Fund Families\n",
    "We restrict the clustering analysis to the 15 largest fund families, measured primarily by total final AUM and client coverage.\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "9cabda05",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Top 15 families:\n",
      "01 - Carmignac Patrimoine\n",
      "02 - Carmignac Sécurité\n",
      "03 - Carmignac Investissement\n",
      "04 - Carmignac Credit <NUM>\n",
      "05 - Carmignac Portfolio Sécurité\n",
      "06 - Carmignac Portfolio Flexible Bond\n",
      "07 - Carmignac Portfolio Credit\n",
      "08 - Carmignac Emergents\n",
      "09 - Carmignac Court Terme\n",
      "10 - Carmignac Portfolio Long-Short European Equities\n",
      "11 - Carmignac Portfolio Grande Europe\n",
      "12 - Carmignac Portfolio Emergents\n",
      "13 - Carmignac Portfolio Global Bond\n",
      "14 - Carmignac Portfolio Patrimoine\n",
      "15 - Carmignac Portfolio Emerging Patrimoine\n"
     ]
    },
    {
     "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>fund_family</th>\n",
       "      <th>n_clients</th>\n",
       "      <th>total_family_aum</th>\n",
       "      <th>avg_family_aum</th>\n",
       "      <th>total_gross_flow</th>\n",
       "      <th>total_tx</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>6183</td>\n",
       "      <td>6.668324e+09</td>\n",
       "      <td>2.730239e+06</td>\n",
       "      <td>1.199596e+07</td>\n",
       "      <td>49953.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "      <td>2825</td>\n",
       "      <td>5.359539e+09</td>\n",
       "      <td>3.274706e+06</td>\n",
       "      <td>5.239893e+06</td>\n",
       "      <td>36860.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Carmignac Investissement</td>\n",
       "      <td>4982</td>\n",
       "      <td>4.111151e+09</td>\n",
       "      <td>9.593080e+05</td>\n",
       "      <td>1.304787e+06</td>\n",
       "      <td>20269.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Carmignac Credit &lt;NUM&gt;</td>\n",
       "      <td>436</td>\n",
       "      <td>4.082249e+09</td>\n",
       "      <td>4.098273e+06</td>\n",
       "      <td>5.065680e+06</td>\n",
       "      <td>6893.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "      <td>1264</td>\n",
       "      <td>2.688287e+09</td>\n",
       "      <td>2.178355e+06</td>\n",
       "      <td>1.756042e+07</td>\n",
       "      <td>13177.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "      <td>1431</td>\n",
       "      <td>2.483972e+09</td>\n",
       "      <td>1.498464e+06</td>\n",
       "      <td>1.029621e+06</td>\n",
       "      <td>12046.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "      <td>1135</td>\n",
       "      <td>2.356507e+09</td>\n",
       "      <td>1.132726e+06</td>\n",
       "      <td>4.493724e+06</td>\n",
       "      <td>8018.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Carmignac Emergents</td>\n",
       "      <td>4231</td>\n",
       "      <td>1.095901e+09</td>\n",
       "      <td>3.089076e+05</td>\n",
       "      <td>2.353374e+06</td>\n",
       "      <td>12011.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "      <td>1331</td>\n",
       "      <td>9.948195e+08</td>\n",
       "      <td>3.681887e+05</td>\n",
       "      <td>2.222615e+05</td>\n",
       "      <td>5745.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "      <td>689</td>\n",
       "      <td>7.283139e+08</td>\n",
       "      <td>1.129733e+06</td>\n",
       "      <td>3.032355e+06</td>\n",
       "      <td>4884.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>2950</td>\n",
       "      <td>5.882891e+08</td>\n",
       "      <td>2.852247e+05</td>\n",
       "      <td>2.061285e+06</td>\n",
       "      <td>9341.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Carmignac Portfolio Emergents</td>\n",
       "      <td>650</td>\n",
       "      <td>5.466360e+08</td>\n",
       "      <td>6.443657e+05</td>\n",
       "      <td>1.722755e+06</td>\n",
       "      <td>9211.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "      <td>2114</td>\n",
       "      <td>5.445575e+08</td>\n",
       "      <td>4.059678e+05</td>\n",
       "      <td>3.476952e+06</td>\n",
       "      <td>18356.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "      <td>1234</td>\n",
       "      <td>5.127245e+08</td>\n",
       "      <td>7.907827e+05</td>\n",
       "      <td>5.253474e+06</td>\n",
       "      <td>9133.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "      <td>1673</td>\n",
       "      <td>3.315211e+08</td>\n",
       "      <td>4.169396e+05</td>\n",
       "      <td>3.368469e+06</td>\n",
       "      <td>13732.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         fund_family  n_clients  \\\n",
       "0                               Carmignac Patrimoine       6183   \n",
       "1                                 Carmignac Sécurité       2825   \n",
       "2                           Carmignac Investissement       4982   \n",
       "3                             Carmignac Credit <NUM>        436   \n",
       "4                       Carmignac Portfolio Sécurité       1264   \n",
       "5                  Carmignac Portfolio Flexible Bond       1431   \n",
       "6                         Carmignac Portfolio Credit       1135   \n",
       "7                                Carmignac Emergents       4231   \n",
       "8                              Carmignac Court Terme       1331   \n",
       "9   Carmignac Portfolio Long-Short European Equities        689   \n",
       "10                 Carmignac Portfolio Grande Europe       2950   \n",
       "11                     Carmignac Portfolio Emergents        650   \n",
       "12                   Carmignac Portfolio Global Bond       2114   \n",
       "13                    Carmignac Portfolio Patrimoine       1234   \n",
       "14           Carmignac Portfolio Emerging Patrimoine       1673   \n",
       "\n",
       "    total_family_aum  avg_family_aum  total_gross_flow  total_tx  \n",
       "0       6.668324e+09    2.730239e+06      1.199596e+07   49953.0  \n",
       "1       5.359539e+09    3.274706e+06      5.239893e+06   36860.0  \n",
       "2       4.111151e+09    9.593080e+05      1.304787e+06   20269.0  \n",
       "3       4.082249e+09    4.098273e+06      5.065680e+06    6893.0  \n",
       "4       2.688287e+09    2.178355e+06      1.756042e+07   13177.0  \n",
       "5       2.483972e+09    1.498464e+06      1.029621e+06   12046.0  \n",
       "6       2.356507e+09    1.132726e+06      4.493724e+06    8018.0  \n",
       "7       1.095901e+09    3.089076e+05      2.353374e+06   12011.0  \n",
       "8       9.948195e+08    3.681887e+05      2.222615e+05    5745.0  \n",
       "9       7.283139e+08    1.129733e+06      3.032355e+06    4884.0  \n",
       "10      5.882891e+08    2.852247e+05      2.061285e+06    9341.0  \n",
       "11      5.466360e+08    6.443657e+05      1.722755e+06    9211.0  \n",
       "12      5.445575e+08    4.059678e+05      3.476952e+06   18356.0  \n",
       "13      5.127245e+08    7.907827e+05      5.253474e+06    9133.0  \n",
       "14      3.315211e+08    4.169396e+05      3.368469e+06   13732.0  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 28 - Table des top families\n",
    "\n",
    "top_family_table = (\n",
    "    df_family_client_base\n",
    "    .groupby(\"fund_family\", as_index=False)\n",
    "    .agg(\n",
    "        n_clients=(ID_COL, \"nunique\"),\n",
    "        total_family_aum=(\"family_aum_val_last\", \"sum\"),\n",
    "        avg_family_aum=(\"family_aum_val_mean\", \"mean\"),\n",
    "        total_gross_flow=(\"gross_flow_qty_sum\", \"sum\"),\n",
    "        total_tx=(\"n_tx_total\", \"sum\")\n",
    "    )\n",
    "    .sort_values([\"total_family_aum\", \"n_clients\"], ascending=[False, False])\n",
    "    .reset_index(drop=True)\n",
    ")\n",
    "\n",
    "top_15_families = top_family_table.head(15)[\"fund_family\"].tolist()\n",
    "\n",
    "print(\"Top 15 families:\")\n",
    "for i, fam in enumerate(top_15_families, 1):\n",
    "    print(f\"{i:02d} - {fam}\")\n",
    "\n",
    "top_family_table.head(15)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "3be8b56b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 91072 characters]",
      "text/plain": [
       "<Figure size 1200x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 91668 characters]",
      "text/plain": [
       "<Figure size 1200x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 29 - Visualisation des top 15 families\n",
    "\n",
    "top15_plot = top_family_table.head(15).copy()\n",
    "\n",
    "plt.figure(figsize=(12, 6))\n",
    "sns.barplot(data=top15_plot, y=\"fund_family\", x=\"total_family_aum\")\n",
    "plt.title(\"Top 15 fund families by total AUM\")\n",
    "plt.xlabel(\"Total family AUM\")\n",
    "plt.ylabel(\"Fund family\")\n",
    "plt.tight_layout()\n",
    "plt.show()\n",
    "\n",
    "plt.figure(figsize=(12, 6))\n",
    "sns.barplot(data=top15_plot, y=\"fund_family\", x=\"n_clients\")\n",
    "plt.title(\"Top 15 fund families by number of clients\")\n",
    "plt.xlabel(\"Number of clients\")\n",
    "plt.ylabel(\"Fund family\")\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b5257a3",
   "metadata": {},
   "source": [
    "---\n",
    "## 6. Part 2 — Additional Performance Features for Family Clustering\n",
    "We enrich the `client × family` dataset with two types of performance-sensitive variables computed from the monthly family panel:\n",
    "\n",
    "1. **Correlation between flow intensity and past family performance**, using rolling average returns over 3 and 6 months.\n",
    "2. **Buy-after-good-performance shares**, i.e. the proportion of buy months occurring after positive rolling average returns.\n",
    "\n",
    "These variables extend the original notebook by explicitly measuring momentum-like behavior at fund-family level.\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "3ae47862",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Performance features merged. Shape: (53891, 53)\n"
     ]
    },
    {
     "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>Registrar Account - ID</th>\n",
       "      <th>fund_family</th>\n",
       "      <th>corr_flow_ret_3m</th>\n",
       "      <th>corr_flow_ret_6m</th>\n",
       "      <th>buy_after_good_perf_share_3m</th>\n",
       "      <th>buy_after_good_perf_share_6m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100000014</td>\n",
       "      <td>Carmignac Portfolio Climate Transition</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100000016</td>\n",
       "      <td>Carmignac Emergents</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100000016</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100000028</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>0.258199</td>\n",
       "      <td>0.258199</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>100000038</td>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Registrar Account - ID                             fund_family  \\\n",
       "0              100000014  Carmignac Portfolio Climate Transition   \n",
       "1              100000016                     Carmignac Emergents   \n",
       "2              100000016                    Carmignac Patrimoine   \n",
       "3              100000028                    Carmignac Patrimoine   \n",
       "4              100000038                    Carmignac Patrimoine   \n",
       "\n",
       "   corr_flow_ret_3m  corr_flow_ret_6m  buy_after_good_perf_share_3m  \\\n",
       "0          0.000000          0.000000                           0.0   \n",
       "1          0.000000          0.000000                           0.0   \n",
       "2          0.000000          0.000000                           0.0   \n",
       "3          0.258199          0.258199                           0.0   \n",
       "4          0.000000          0.000000                           0.0   \n",
       "\n",
       "   buy_after_good_perf_share_6m  \n",
       "0                           0.0  \n",
       "1                           0.0  \n",
       "2                           0.0  \n",
       "3                           0.0  \n",
       "4                           0.0  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 30 - Additional performance features for family clustering\n",
    "\n",
    "def safe_corr(x, y, min_obs=6):\n",
    "    x = pd.Series(x, dtype=float)\n",
    "    y = pd.Series(y, dtype=float)\n",
    "    mask = x.notna() & y.notna()\n",
    "    x = x[mask]\n",
    "    y = y[mask]\n",
    "    if len(x) < min_obs or x.nunique() <= 1 or y.nunique() <= 1:\n",
    "        return np.nan\n",
    "    return x.corr(y)\n",
    "\n",
    "tmp_perf = tmp.copy()\n",
    "\n",
    "# Past family returns already available in tmp:\n",
    "# ret_fund_mean3_lag1 and ret_fund_mean6_lag1\n",
    "\n",
    "tmp_perf[\"buy_flag\"] = (tmp_perf[\"net_flow_qty\"] > 0).astype(int)\n",
    "tmp_perf[\"good_perf_3m\"] = (tmp_perf[\"ret_fund_mean3_lag1\"] > 0).astype(int)\n",
    "tmp_perf[\"good_perf_6m\"] = (tmp_perf[\"ret_fund_mean6_lag1\"] > 0).astype(int)\n",
    "\n",
    "perf_rows = []\n",
    "for (acc, fam), g in tmp_perf.groupby([ID_COL, \"fund_family\"]):\n",
    "    g = g.sort_values(\"month\")\n",
    "\n",
    "    buy_months = g[\"buy_flag\"].sum()\n",
    "\n",
    "    perf_rows.append({\n",
    "        ID_COL: acc,\n",
    "        \"fund_family\": fam,\n",
    "        \"corr_flow_ret_3m\": safe_corr(g[\"flow_to_aum_m\"], g[\"ret_fund_mean3_lag1\"], min_obs=6),\n",
    "        \"corr_flow_ret_6m\": safe_corr(g[\"flow_to_aum_m\"], g[\"ret_fund_mean6_lag1\"], min_obs=6),\n",
    "        \"buy_after_good_perf_share_3m\": (\n",
    "            ((g[\"buy_flag\"] == 1) & (g[\"good_perf_3m\"] == 1)).sum() / buy_months\n",
    "            if buy_months > 0 else np.nan\n",
    "        ),\n",
    "        \"buy_after_good_perf_share_6m\": (\n",
    "            ((g[\"buy_flag\"] == 1) & (g[\"good_perf_6m\"] == 1)).sum() / buy_months\n",
    "            if buy_months > 0 else np.nan\n",
    "        ),\n",
    "    })\n",
    "\n",
    "df_family_perf = pd.DataFrame(perf_rows)\n",
    "\n",
    "# Merge into final family-level table\n",
    "df_family_client_base = df_family_client_base.merge(\n",
    "    df_family_perf,\n",
    "    on=[ID_COL, \"fund_family\"],\n",
    "    how=\"left\"\n",
    ")\n",
    "\n",
    "for col in [\"corr_flow_ret_3m\", \"corr_flow_ret_6m\",\n",
    "            \"buy_after_good_perf_share_3m\", \"buy_after_good_perf_share_6m\"]:\n",
    "    if col in df_family_client_base.columns:\n",
    "        df_family_client_base[col] = df_family_client_base[col].fillna(0)\n",
    "\n",
    "print(\"Performance features merged. Shape:\", df_family_client_base.shape)\n",
    "df_family_client_base[\n",
    "    [ID_COL, \"fund_family\", \"corr_flow_ret_3m\", \"corr_flow_ret_6m\",\n",
    "     \"buy_after_good_perf_share_3m\", \"buy_after_good_perf_share_6m\"]\n",
    "].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b781457",
   "metadata": {},
   "source": [
    "---\n",
    "## 7. Part 3 — Clustering Features\n",
    "To stay close to the original global clustering notebook, we keep a compact set of core behavioral variables:\n",
    "- activity frequency\n",
    "- gross flow intensity relative to average AUM\n",
    "- family concentration/importance\n",
    "- exit behavior\n",
    "- flow direction balance\n",
    "- recency of activity\n",
    "\n",
    "We then add the new **performance-sensitive features** and the **rolling turnover averages**, which are central to the family-fund approach.\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "2d120f23",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of clustering features: 15\n",
      "['flow_freq', 'gross_flow_to_aum_family', 'avg_n_isin_held', 'exit_rate_per_isin_family', 'flow_direction_balance', 'log_family_aum_val_mean', 'months_since_last_tx_family', 'family_share_of_client_aum_mean', 'turnover_mean3_avg', 'turnover_mean6_avg', 'turnover_mean12_avg', 'corr_flow_ret_3m', 'corr_flow_ret_6m', 'buy_after_good_perf_share_3m', 'buy_after_good_perf_share_6m']\n"
     ]
    }
   ],
   "source": [
    "# 31 - Final clustering features\n",
    "\n",
    "# Derived ratios closer to the initial notebook\n",
    "df_family_client_base[\"log_family_aum_val_mean\"] = np.log1p(\n",
    "    df_family_client_base[\"family_aum_val_mean\"].clip(lower=0)\n",
    ")\n",
    "\n",
    "df_family_client_base[\"gross_flow_to_aum_family\"] = np.where(\n",
    "    df_family_client_base[\"family_aum_qty_mean\"].abs() > 1,\n",
    "    df_family_client_base[\"gross_flow_qty_sum\"] / df_family_client_base[\"family_aum_qty_mean\"].abs(),\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_client_base[\"flow_direction_balance\"] = np.where(\n",
    "    df_family_client_base[\"gross_flow_qty_sum\"] > 0,\n",
    "    df_family_client_base[\"net_flow_qty_sum\"] / df_family_client_base[\"gross_flow_qty_sum\"],\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_client_base[\"exit_rate_per_isin_family\"] = np.where(\n",
    "    df_family_client_base[\"avg_n_isin_held\"] > 0,\n",
    "    df_family_client_base[\"full_exit_count\"] / df_family_client_base[\"avg_n_isin_held\"],\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_client_base[\"family_aum_final_to_peak\"] = np.where(\n",
    "    df_family_client_base[\"family_aum_qty_max\"] > 0,\n",
    "    df_family_client_base[\"family_aum_qty_last\"] / df_family_client_base[\"family_aum_qty_max\"],\n",
    "    np.nan\n",
    ")\n",
    "\n",
    "df_family_client_base[\"aum_drawdown_last\"] = df_family_client_base[\"aum_drawdown_last\"].clip(0, 1)\n",
    "df_family_client_base[\"family_aum_final_to_peak\"] = df_family_client_base[\"family_aum_final_to_peak\"].clip(0, 1)\n",
    "\n",
    "# Compact but rich feature list\n",
    "family_cluster_features = [\n",
    "    \"flow_freq\",\n",
    "    \"gross_flow_to_aum_family\",\n",
    "    \"avg_n_isin_held\",\n",
    "    \"exit_rate_per_isin_family\",\n",
    "    \"flow_direction_balance\",\n",
    "    \"log_family_aum_val_mean\",\n",
    "    \"months_since_last_tx_family\",\n",
    "    \"family_share_of_client_aum_mean\",\n",
    "    \"turnover_mean3_avg\",\n",
    "    \"turnover_mean6_avg\",\n",
    "    \"turnover_mean12_avg\",\n",
    "    \"corr_flow_ret_3m\",\n",
    "    \"corr_flow_ret_6m\",\n",
    "    \"buy_after_good_perf_share_3m\",\n",
    "    \"buy_after_good_perf_share_6m\",\n",
    "]\n",
    "\n",
    "print(\"Number of clustering features:\", len(family_cluster_features))\n",
    "print(family_cluster_features)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e455f9cf",
   "metadata": {},
   "source": [
    "---\n",
    "## 8. Part 4 — Robust Clustering Utilities\n",
    "Compared with the first family notebook version, the functions below:\n",
    "- apply **stronger filtering of outliers**\n",
    "- winsorize a broader set of variables\n",
    "- reject values of `K` that create **tiny clusters**\n",
    "- therefore avoid the pathological case “one giant cluster + one or two clients alone”\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "8b43106b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 32 - Robust clustering helpers\n",
    "\n",
    "from sklearn.decomposition import PCA\n",
    "from sklearn.impute import SimpleImputer\n",
    "\n",
    "def prepare_family_matrix(df_family, features, winsorize_cols=None):\n",
    "    X = df_family[features].copy()\n",
    "\n",
    "    # Median imputation\n",
    "    imputer = SimpleImputer(strategy=\"median\")\n",
    "    X_imp = pd.DataFrame(imputer.fit_transform(X), columns=features, index=X.index)\n",
    "\n",
    "    # Broad winsorization, inspired by the original notebook\n",
    "    if winsorize_cols is None:\n",
    "        winsorize_cols = [\n",
    "            \"gross_flow_to_aum_family\",\n",
    "            \"avg_n_isin_held\",\n",
    "            \"exit_rate_per_isin_family\",\n",
    "            \"months_since_last_tx_family\",\n",
    "            \"family_share_of_client_aum_mean\",\n",
    "            \"turnover_mean3_avg\",\n",
    "            \"turnover_mean6_avg\",\n",
    "            \"turnover_mean12_avg\",\n",
    "        ]\n",
    "\n",
    "    for col in winsorize_cols:\n",
    "        if col in X_imp.columns:\n",
    "            X_imp[col] = winsorize_mad(X_imp[col], n_sigma=3)\n",
    "\n",
    "    # Variables bounded by construction\n",
    "    for col in [\n",
    "        \"flow_freq\",\n",
    "        \"family_share_of_client_aum_mean\",\n",
    "        \"buy_after_good_perf_share_3m\",\n",
    "        \"buy_after_good_perf_share_6m\",\n",
    "        \"family_aum_final_to_peak\"\n",
    "    ]:\n",
    "        if col in X_imp.columns:\n",
    "            X_imp[col] = np.clip(X_imp[col], 0, 1)\n",
    "\n",
    "    # Correlations should live in [-1, 1]\n",
    "    for col in [\"corr_flow_ret_3m\", \"corr_flow_ret_6m\", \"flow_direction_balance\"]:\n",
    "        if col in X_imp.columns:\n",
    "            X_imp[col] = np.clip(X_imp[col], -1, 1)\n",
    "\n",
    "    # Same logic as in the original notebook:\n",
    "    # clip and log-transform gross flow intensity\n",
    "    if \"gross_flow_to_aum_family\" in X_imp.columns:\n",
    "        vals = X_imp[\"gross_flow_to_aum_family\"].to_numpy(dtype=float)\n",
    "        vals = np.clip(vals, 0, np.nanpercentile(vals, 90))\n",
    "        X_imp[\"gross_flow_to_aum_family\"] = np.log1p(vals)\n",
    "\n",
    "    scaler = RobustScaler()\n",
    "    X_scaled = scaler.fit_transform(X_imp)\n",
    "\n",
    "    return X_imp, X_scaled, imputer, scaler\n",
    "\n",
    "\n",
    "def evaluate_k_range(X_scaled, k_min=2, k_max=6, min_cluster_size=10, min_cluster_share=0.02, random_state=42):\n",
    "    n = X_scaled.shape[0]\n",
    "    k_max = min(k_max, max(2, n - 1))\n",
    "\n",
    "    rows = []\n",
    "    for k in range(k_min, k_max + 1):\n",
    "        if k >= n:\n",
    "            continue\n",
    "\n",
    "        km = KMeans(n_clusters=k, random_state=random_state, n_init=20)\n",
    "        labels = km.fit_predict(X_scaled)\n",
    "\n",
    "        cluster_sizes = pd.Series(labels).value_counts().sort_index()\n",
    "        min_size = int(cluster_sizes.min())\n",
    "        min_size_required = max(min_cluster_size, int(np.ceil(min_cluster_share * n)))\n",
    "\n",
    "        valid = (min_size >= min_size_required)\n",
    "\n",
    "        if valid:\n",
    "            sil = silhouette_score(X_scaled, labels)\n",
    "            dbi = davies_bouldin_score(X_scaled, labels)\n",
    "        else:\n",
    "            sil = np.nan\n",
    "            dbi = np.nan\n",
    "\n",
    "        rows.append({\n",
    "            \"k\": k,\n",
    "            \"silhouette\": sil,\n",
    "            \"davies_bouldin\": dbi,\n",
    "            \"min_cluster_size\": min_size,\n",
    "            \"min_cluster_required\": min_size_required,\n",
    "            \"inertia\": km.inertia_,\n",
    "            \"valid_k\": valid\n",
    "        })\n",
    "\n",
    "    return pd.DataFrame(rows)\n",
    "\n",
    "\n",
    "def choose_best_k(metrics_df):\n",
    "    valid = metrics_df[metrics_df[\"valid_k\"]].dropna(subset=[\"silhouette\"]).copy()\n",
    "    if len(valid) == 0:\n",
    "        return None\n",
    "    return int(valid.sort_values([\"silhouette\", \"davies_bouldin\"], ascending=[False, True]).iloc[0][\"k\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "ceb97cfd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 33 - Family clustering pipeline\n",
    "\n",
    "def run_family_clustering(\n",
    "    df_base,\n",
    "    family_name,\n",
    "    features,\n",
    "    k_min=2,\n",
    "    k_max=6,\n",
    "    min_clients=40,\n",
    "    min_cluster_size=10,\n",
    "    min_cluster_share=0.02,\n",
    "    random_state=42,\n",
    "    make_plots=True\n",
    "):\n",
    "    df_family = df_base[df_base[\"fund_family\"] == family_name].copy()\n",
    "\n",
    "    # Quality filters\n",
    "    df_family = df_family[\n",
    "        (df_family[\"n_months\"] >= 6) &\n",
    "        (df_family[\"family_aum_val_mean\"] > 0)\n",
    "    ].copy()\n",
    "\n",
    "    # Stronger quantile filtering, \n",
    "    for col in [\"family_aum_val_mean\", \"gross_flow_qty_sum\", \"n_tx_total\"]:\n",
    "        if col in df_family.columns and df_family[col].notna().sum() > 0:\n",
    "            cap = df_family[col].quantile(0.99)\n",
    "            df_family = df_family[df_family[col] <= cap].copy()\n",
    "\n",
    "    n_clients = df_family[ID_COL].nunique()\n",
    "    if n_clients < min_clients:\n",
    "        print(f\"[SKIP] {family_name}: only {n_clients} usable clients.\")\n",
    "        return None\n",
    "\n",
    "    X_imp, X_scaled, imputer, scaler = prepare_family_matrix(df_family, features)\n",
    "\n",
    "    metrics_df = evaluate_k_range(\n",
    "        X_scaled,\n",
    "        k_min=k_min,\n",
    "        k_max=k_max,\n",
    "        min_cluster_size=min_cluster_size,\n",
    "        min_cluster_share=min_cluster_share,\n",
    "        random_state=random_state\n",
    "    )\n",
    "\n",
    "    if len(metrics_df) == 0:\n",
    "        print(f\"[SKIP] {family_name}: no K evaluated.\")\n",
    "        return None\n",
    "\n",
    "    best_k = choose_best_k(metrics_df)\n",
    "    if best_k is None:\n",
    "        print(f\"[SKIP] {family_name}: no valid K with cluster size constraints.\")\n",
    "        return None\n",
    "\n",
    "    km = KMeans(n_clusters=best_k, random_state=random_state, n_init=30)\n",
    "    labels = km.fit_predict(X_scaled)\n",
    "\n",
    "    df_family[\"cluster\"] = labels\n",
    "\n",
    "    cluster_sizes = (\n",
    "        df_family[\"cluster\"]\n",
    "        .value_counts()\n",
    "        .sort_index()\n",
    "        .rename_axis(\"cluster\")\n",
    "        .reset_index(name=\"n_clients\")\n",
    "    )\n",
    "\n",
    "    cluster_profile = (\n",
    "        df_family.groupby(\"cluster\")[features]\n",
    "        .median()\n",
    "        .sort_index()\n",
    "    ) #moyenne des features par cluster\n",
    "\n",
    "    # Churn proxies at family level\n",
    "    df_family[\"churn_hard\"] = (df_family[\"family_aum_final_to_peak\"] < 0.10).astype(int)\n",
    "    df_family[\"churn_soft\"] = (\n",
    "        (df_family[\"family_aum_final_to_peak\"] < 0.40) &\n",
    "        (df_family[\"aum_drawdown_last\"] > 0.40)\n",
    "    ).astype(int)\n",
    "    df_family[\"churn_warning\"] = (\n",
    "        (df_family[\"flow_direction_balance\"] < 0) &\n",
    "        (df_family[\"aum_drawdown_last\"] > 0.20)\n",
    "    ).astype(int)\n",
    "\n",
    "    churn_profile = (\n",
    "        df_family.groupby(\"cluster\")[[\"churn_hard\", \"churn_soft\", \"churn_warning\"]]\n",
    "        .mean()\n",
    "        .sort_index()\n",
    "    )\n",
    "\n",
    "    # PCA for visualization\n",
    "    pca = PCA(n_components=2, random_state=random_state)\n",
    "    coords = pca.fit_transform(X_scaled)\n",
    "    df_family[\"pca1\"] = coords[:, 0]\n",
    "    df_family[\"pca2\"] = coords[:, 1]\n",
    "\n",
    "    result = {\n",
    "        \"family\": family_name,\n",
    "        \"n_clients\": n_clients,\n",
    "        \"best_k\": best_k,\n",
    "        \"metrics_df\": metrics_df,\n",
    "        \"df_family\": df_family,\n",
    "        \"cluster_profile\": cluster_profile,\n",
    "        \"cluster_sizes\": cluster_sizes,\n",
    "        \"churn_profile\": churn_profile,\n",
    "        \"features\": features,\n",
    "        \"pca_explained_var\": pca.explained_variance_ratio_,\n",
    "    }\n",
    "\n",
    "    if make_plots:\n",
    "        # Choice of K\n",
    "        fig, axes = plt.subplots(1, 3, figsize=(15, 4))\n",
    "        axes[0].plot(metrics_df[\"k\"], metrics_df[\"silhouette\"], marker=\"o\")\n",
    "        axes[0].set_title(f\"{family_name} - Silhouette\")\n",
    "        axes[0].set_xlabel(\"k\")\n",
    "\n",
    "        axes[1].plot(metrics_df[\"k\"], metrics_df[\"davies_bouldin\"], marker=\"o\")\n",
    "        axes[1].set_title(f\"{family_name} - Davies-Bouldin\")\n",
    "        axes[1].set_xlabel(\"k\")\n",
    "\n",
    "        axes[2].plot(metrics_df[\"k\"], metrics_df[\"inertia\"], marker=\"o\")\n",
    "        axes[2].set_title(f\"{family_name} - Inertia\")\n",
    "        axes[2].set_xlabel(\"k\")\n",
    "        plt.tight_layout()\n",
    "        plt.show()\n",
    "\n",
    "        # Cluster signatures\n",
    "        plot_heatmap(\n",
    "            df_family,\n",
    "            profile_vars=features,\n",
    "            cluster_col=\"cluster\",\n",
    "            title=f\"{family_name} - Cluster signatures\",\n",
    "            figsize=(18, 5)\n",
    "        )\n",
    "\n",
    "        # PCA projection\n",
    "        plt.figure(figsize=(7, 5))\n",
    "        sns.scatterplot(\n",
    "            data=df_family,\n",
    "            x=\"pca1\", y=\"pca2\",\n",
    "            hue=\"cluster\",\n",
    "            palette=\"tab10\",\n",
    "            alpha=0.8\n",
    "        )\n",
    "        plt.title(\n",
    "            f\"{family_name} - PCA projection \"\n",
    "            f\"(explained var: {result['pca_explained_var'][0]:.2f}, {result['pca_explained_var'][1]:.2f})\"\n",
    "        )\n",
    "        plt.tight_layout()\n",
    "        plt.show()\n",
    "\n",
    "        # Cluster sizes\n",
    "        plt.figure(figsize=(6, 4))\n",
    "        sns.barplot(data=cluster_sizes, x=\"cluster\", y=\"n_clients\")\n",
    "        plt.title(f\"{family_name} - Cluster sizes\")\n",
    "        plt.tight_layout()\n",
    "        plt.show()\n",
    "\n",
    "        # Churn by cluster\n",
    "        churn_long = churn_profile.reset_index().melt(\n",
    "            id_vars=\"cluster\",\n",
    "            value_vars=[\"churn_hard\", \"churn_soft\", \"churn_warning\"],\n",
    "            var_name=\"churn_type\",\n",
    "            value_name=\"rate\"\n",
    "        )\n",
    "\n",
    "        plt.figure(figsize=(8, 4))\n",
    "        sns.barplot(data=churn_long, x=\"cluster\", y=\"rate\", hue=\"churn_type\")\n",
    "        plt.title(f\"{family_name} - Churn analysis by cluster\")\n",
    "        plt.ylabel(\"Rate\")\n",
    "        plt.tight_layout()\n",
    "        plt.show()\n",
    "\n",
    "        print(f\"\\n=== {family_name} ===\")\n",
    "        print(f\"Clients after filtering: {n_clients}\")\n",
    "        print(f\"Chosen K: {best_k}\")\n",
    "        print(cluster_sizes)\n",
    "        print(\"\\nChurn profile:\")\n",
    "        print(churn_profile.round(3))\n",
    "\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "b1161a03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 48480 characters]",
      "text/plain": [
       "<Figure size 1500x400 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 161264 characters]",
      "text/plain": [
       "<Figure size 1800x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 86612 characters]",
      "text/plain": [
       "<Figure size 700x500 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 20384 characters]",
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 30108 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== Carmignac Patrimoine ===\n",
      "Clients after filtering: 3058\n",
      "Chosen K: 4\n",
      "   cluster  n_clients\n",
      "0        0       2601\n",
      "1        1        172\n",
      "2        2        200\n",
      "3        3         85\n",
      "\n",
      "Churn profile:\n",
      "         churn_hard  churn_soft  churn_warning\n",
      "cluster                                       \n",
      "0             0.688       0.765          0.129\n",
      "1             0.907       0.953          0.750\n",
      "2             0.745       0.870          0.700\n",
      "3             0.847       0.918          0.765\n"
     ]
    }
   ],
   "source": [
    "# 34 - Test on one family\n",
    "\n",
    "test_family = top_15_families[0]\n",
    "result_test = run_family_clustering(\n",
    "    df_base=df_family_client_base,\n",
    "    family_name=test_family,\n",
    "    features=family_cluster_features,\n",
    "    k_min=4,\n",
    "    k_max=10,\n",
    "    min_clients=40,\n",
    "    min_cluster_size=10,\n",
    "    min_cluster_share=0.02,\n",
    "    random_state=RANDOM_STATE,\n",
    "    make_plots=True\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "e339c5fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Patrimoine\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Sécurité\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Investissement\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Credit <NUM>\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Sécurité\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Flexible Bond\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Credit\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Emergents\n",
      "==========================================================================================\n",
      "[SKIP] Carmignac Emergents: no valid K with cluster size constraints.\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Court Terme\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Long-Short European Equities\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Grande Europe\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Emergents\n",
      "==========================================================================================\n",
      "[SKIP] Carmignac Portfolio Emergents: no valid K with cluster size constraints.\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Global Bond\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Patrimoine\n",
      "==========================================================================================\n",
      "\n",
      "==========================================================================================\n",
      "Running clustering for family: Carmignac Portfolio Emerging Patrimoine\n",
      "==========================================================================================\n"
     ]
    },
    {
     "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>fund_family</th>\n",
       "      <th>n_clients</th>\n",
       "      <th>best_k</th>\n",
       "      <th>silhouette</th>\n",
       "      <th>davies_bouldin</th>\n",
       "      <th>min_cluster_size</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>3058</td>\n",
       "      <td>4</td>\n",
       "      <td>0.882916</td>\n",
       "      <td>0.443551</td>\n",
       "      <td>85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Carmignac Investissement</td>\n",
       "      <td>2126</td>\n",
       "      <td>4</td>\n",
       "      <td>0.872248</td>\n",
       "      <td>0.450959</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>1344</td>\n",
       "      <td>4</td>\n",
       "      <td>0.863874</td>\n",
       "      <td>0.466761</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "      <td>1099</td>\n",
       "      <td>5</td>\n",
       "      <td>0.776536</td>\n",
       "      <td>0.690654</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "      <td>586</td>\n",
       "      <td>4</td>\n",
       "      <td>0.717091</td>\n",
       "      <td>0.635826</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "      <td>507</td>\n",
       "      <td>4</td>\n",
       "      <td>0.714238</td>\n",
       "      <td>0.690596</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "      <td>1573</td>\n",
       "      <td>4</td>\n",
       "      <td>0.697358</td>\n",
       "      <td>0.776298</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "      <td>1053</td>\n",
       "      <td>4</td>\n",
       "      <td>0.675407</td>\n",
       "      <td>0.801578</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Carmignac Credit &lt;NUM&gt;</td>\n",
       "      <td>370</td>\n",
       "      <td>4</td>\n",
       "      <td>0.535035</td>\n",
       "      <td>0.998164</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "      <td>1664</td>\n",
       "      <td>4</td>\n",
       "      <td>0.532877</td>\n",
       "      <td>0.680604</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "      <td>1125</td>\n",
       "      <td>4</td>\n",
       "      <td>0.451412</td>\n",
       "      <td>0.935678</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "      <td>984</td>\n",
       "      <td>4</td>\n",
       "      <td>0.366476</td>\n",
       "      <td>1.024236</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "      <td>1107</td>\n",
       "      <td>5</td>\n",
       "      <td>0.296463</td>\n",
       "      <td>1.068490</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         fund_family  n_clients  best_k  \\\n",
       "0                               Carmignac Patrimoine       3058       4   \n",
       "1                           Carmignac Investissement       2126       4   \n",
       "2                  Carmignac Portfolio Grande Europe       1344       4   \n",
       "3            Carmignac Portfolio Emerging Patrimoine       1099       5   \n",
       "4   Carmignac Portfolio Long-Short European Equities        586       4   \n",
       "5                              Carmignac Court Terme        507       4   \n",
       "6                                 Carmignac Sécurité       1573       4   \n",
       "7                  Carmignac Portfolio Flexible Bond       1053       4   \n",
       "8                             Carmignac Credit <NUM>        370       4   \n",
       "9                    Carmignac Portfolio Global Bond       1664       4   \n",
       "10                      Carmignac Portfolio Sécurité       1125       4   \n",
       "11                        Carmignac Portfolio Credit        984       4   \n",
       "12                    Carmignac Portfolio Patrimoine       1107       5   \n",
       "\n",
       "    silhouette  davies_bouldin  min_cluster_size  \n",
       "0     0.882916        0.443551                85  \n",
       "1     0.872248        0.450959                74  \n",
       "2     0.863874        0.466761                40  \n",
       "3     0.776536        0.690654                26  \n",
       "4     0.717091        0.635826                28  \n",
       "5     0.714238        0.690596                17  \n",
       "6     0.697358        0.776298                86  \n",
       "7     0.675407        0.801578                40  \n",
       "8     0.535035        0.998164                23  \n",
       "9     0.532877        0.680604                70  \n",
       "10    0.451412        0.935678                46  \n",
       "11    0.366476        1.024236                48  \n",
       "12    0.296463        1.068490                29  "
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 35 - Run clustering on the top 15 fund families\n",
    "\n",
    "family_results = {}\n",
    "family_summary_rows = []\n",
    "\n",
    "for fam in top_15_families:\n",
    "    print(\"\\n\" + \"=\" * 90)\n",
    "    print(f\"Running clustering for family: {fam}\")\n",
    "    print(\"=\" * 90)\n",
    "\n",
    "    res = run_family_clustering(\n",
    "        df_base=df_family_client_base,\n",
    "        family_name=fam,\n",
    "        features=family_cluster_features,\n",
    "        k_min=4,\n",
    "        k_max=10,\n",
    "        min_clients=40,\n",
    "        min_cluster_size=10,\n",
    "        min_cluster_share=0.02,\n",
    "        random_state=RANDOM_STATE,\n",
    "        make_plots=False\n",
    "    )\n",
    "\n",
    "    if res is not None:\n",
    "        family_results[fam] = res\n",
    "        best_row = res[\"metrics_df\"].loc[res[\"metrics_df\"][\"k\"] == res[\"best_k\"]].iloc[0]\n",
    "\n",
    "        family_summary_rows.append({\n",
    "            \"fund_family\": fam,\n",
    "            \"n_clients\": res[\"n_clients\"],\n",
    "            \"best_k\": res[\"best_k\"],\n",
    "            \"silhouette\": best_row[\"silhouette\"],\n",
    "            \"davies_bouldin\": best_row[\"davies_bouldin\"],\n",
    "            \"min_cluster_size\": int(best_row[\"min_cluster_size\"]),\n",
    "        })\n",
    "\n",
    "family_summary = pd.DataFrame(family_summary_rows).sort_values(\n",
    "    [\"silhouette\", \"n_clients\"],\n",
    "    ascending=[False, False]\n",
    ").reset_index(drop=True)\n",
    "\n",
    "family_summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "f5c7e517",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 48480 characters]",
      "text/plain": [
       "<Figure size 1500x400 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 161264 characters]",
      "text/plain": [
       "<Figure size 1800x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 86612 characters]",
      "text/plain": [
       "<Figure size 700x500 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 20384 characters]",
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 30108 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== Carmignac Patrimoine ===\n",
      "Clients after filtering: 3058\n",
      "Chosen K: 4\n",
      "   cluster  n_clients\n",
      "0        0       2601\n",
      "1        1        172\n",
      "2        2        200\n",
      "3        3         85\n",
      "\n",
      "Churn profile:\n",
      "         churn_hard  churn_soft  churn_warning\n",
      "cluster                                       \n",
      "0             0.688       0.765          0.129\n",
      "1             0.907       0.953          0.750\n",
      "2             0.745       0.870          0.700\n",
      "3             0.847       0.918          0.765\n"
     ]
    }
   ],
   "source": [
    "# 36 - Visual and business review for one selected family\n",
    "\n",
    "selected_family = top_15_families[0]\n",
    "if selected_family in family_results:\n",
    "    _ = run_family_clustering(\n",
    "        df_base=df_family_client_base,\n",
    "        family_name=selected_family,\n",
    "        features=family_cluster_features,\n",
    "        k_min=4,\n",
    "        k_max=10,\n",
    "        min_clients=40,\n",
    "        min_cluster_size=10,\n",
    "        min_cluster_share=0.02,\n",
    "        random_state=RANDOM_STATE,\n",
    "        make_plots=True\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "4ba643a5",
   "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>fund_family</th>\n",
       "      <th>n_clients</th>\n",
       "      <th>best_k</th>\n",
       "      <th>silhouette</th>\n",
       "      <th>davies_bouldin</th>\n",
       "      <th>min_cluster_size</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Carmignac Patrimoine</td>\n",
       "      <td>3058</td>\n",
       "      <td>4</td>\n",
       "      <td>0.882916</td>\n",
       "      <td>0.443551</td>\n",
       "      <td>85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Carmignac Investissement</td>\n",
       "      <td>2126</td>\n",
       "      <td>4</td>\n",
       "      <td>0.872248</td>\n",
       "      <td>0.450959</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Carmignac Portfolio Grande Europe</td>\n",
       "      <td>1344</td>\n",
       "      <td>4</td>\n",
       "      <td>0.863874</td>\n",
       "      <td>0.466761</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Carmignac Portfolio Emerging Patrimoine</td>\n",
       "      <td>1099</td>\n",
       "      <td>5</td>\n",
       "      <td>0.776536</td>\n",
       "      <td>0.690654</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Carmignac Portfolio Long-Short European Equities</td>\n",
       "      <td>586</td>\n",
       "      <td>4</td>\n",
       "      <td>0.717091</td>\n",
       "      <td>0.635826</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Carmignac Court Terme</td>\n",
       "      <td>507</td>\n",
       "      <td>4</td>\n",
       "      <td>0.714238</td>\n",
       "      <td>0.690596</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Carmignac Sécurité</td>\n",
       "      <td>1573</td>\n",
       "      <td>4</td>\n",
       "      <td>0.697358</td>\n",
       "      <td>0.776298</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Carmignac Portfolio Flexible Bond</td>\n",
       "      <td>1053</td>\n",
       "      <td>4</td>\n",
       "      <td>0.675407</td>\n",
       "      <td>0.801578</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Carmignac Credit &lt;NUM&gt;</td>\n",
       "      <td>370</td>\n",
       "      <td>4</td>\n",
       "      <td>0.535035</td>\n",
       "      <td>0.998164</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Carmignac Portfolio Global Bond</td>\n",
       "      <td>1664</td>\n",
       "      <td>4</td>\n",
       "      <td>0.532877</td>\n",
       "      <td>0.680604</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Carmignac Portfolio Sécurité</td>\n",
       "      <td>1125</td>\n",
       "      <td>4</td>\n",
       "      <td>0.451412</td>\n",
       "      <td>0.935678</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Carmignac Portfolio Credit</td>\n",
       "      <td>984</td>\n",
       "      <td>4</td>\n",
       "      <td>0.366476</td>\n",
       "      <td>1.024236</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Carmignac Portfolio Patrimoine</td>\n",
       "      <td>1107</td>\n",
       "      <td>5</td>\n",
       "      <td>0.296463</td>\n",
       "      <td>1.068490</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         fund_family  n_clients  best_k  \\\n",
       "0                               Carmignac Patrimoine       3058       4   \n",
       "1                           Carmignac Investissement       2126       4   \n",
       "2                  Carmignac Portfolio Grande Europe       1344       4   \n",
       "3            Carmignac Portfolio Emerging Patrimoine       1099       5   \n",
       "4   Carmignac Portfolio Long-Short European Equities        586       4   \n",
       "5                              Carmignac Court Terme        507       4   \n",
       "6                                 Carmignac Sécurité       1573       4   \n",
       "7                  Carmignac Portfolio Flexible Bond       1053       4   \n",
       "8                             Carmignac Credit <NUM>        370       4   \n",
       "9                    Carmignac Portfolio Global Bond       1664       4   \n",
       "10                      Carmignac Portfolio Sécurité       1125       4   \n",
       "11                        Carmignac Portfolio Credit        984       4   \n",
       "12                    Carmignac Portfolio Patrimoine       1107       5   \n",
       "\n",
       "    silhouette  davies_bouldin  min_cluster_size  \n",
       "0     0.882916        0.443551                85  \n",
       "1     0.872248        0.450959                74  \n",
       "2     0.863874        0.466761                40  \n",
       "3     0.776536        0.690654                26  \n",
       "4     0.717091        0.635826                28  \n",
       "5     0.714238        0.690596                17  \n",
       "6     0.697358        0.776298                86  \n",
       "7     0.675407        0.801578                40  \n",
       "8     0.535035        0.998164                23  \n",
       "9     0.532877        0.680604                70  \n",
       "10    0.451412        0.935678                46  \n",
       "11    0.366476        1.024236                48  \n",
       "12    0.296463        1.068490                29  "
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 37 - Summary table of clustering results across families\n",
    "family_summary"
   ]
  }
 ],
 "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.13.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
