{"slug": "pandas-3-1-filter-selecting-rows-with-a-pd-col-condition", "title": "Pandas 3.1 filter: Selecting rows with a pd.col condition", "summary": "Pandas 3.1 introduces a filter method that applies a row condition via pd.col, letting users replace .loc[pd.col('passenger_count') > 1, 'trip_distance'] with .filter(cond=pd.col('passenger_count') > 1)['trip_distance'], according to a November 8, 2026 post on the release. The post notes the new filter-based form is \"much slower\" than the equivalent .loc expression. The change gives Pandas users an alternative row-selection syntax but at a performance cost versus .loc.", "body_md": "Pandas 3.1 filter: Selecting rows with a pd.col condition\n\nNovember 8, 2026\n\nPython\n\nPython\n\nStarting with Python Pandas 3.1, use “filter” to apply a condition to rows. So:\n\n```\n(\n  df\n  .loc[ pd.col('passenger_count') > 1 , 'trip_distance']\n  .mean()\n)\n```\n\ncan now be (the much slower):\n\n```\n(\n  df\n  .filter(cond=pd.col('passenger_count') > 1)\n  ['trip_distance']\n  .mean()\n)\n```\n\n←\nPandas 3.1 `select` method: Retrieving specific columns\n\nNew course: Introduction to agentic coding with Claude Code\n→", "url": "https://wpnews.pro/news/pandas-3-1-filter-selecting-rows-with-a-pd-col-condition", "canonical_source": "https://lernerpython.com/2026/11/08/pandas-3-1-filter-selecting-rows-with-a-pd-col-condition/", "published_at": "2026-11-08 07:00:00+00:00", "updated_at": "2026-11-11 05:20:58.054935+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Pandas", "Python"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/pandas-3-1-filter-selecting-rows-with-a-pd-col-condition", "markdown": "https://wpnews.pro/news/pandas-3-1-filter-selecting-rows-with-a-pd-col-condition.md", "text": "https://wpnews.pro/news/pandas-3-1-filter-selecting-rows-with-a-pd-col-condition.txt", "jsonld": "https://wpnews.pro/news/pandas-3-1-filter-selecting-rows-with-a-pd-col-condition.jsonld"}}