{
  "id": 382730,
  "title": "Pandas vs Polars: quantile()",
  "url": "/competitions/icecube-neutrinos-in-deep-ice/discussion/382730",
  "author_name": "",
  "post_date": "2023-01-31T21:43:58.245332200Z",
  "votes": 5,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hello!<br>\nwhile converting the pandas script to polars, I found a difference in the result of the <code>quantile()</code>. Given example pandas <code>quantile()</code> returns <code>1.2</code> while polars <code>1.0</code>. Any ideas what is going on?</p>\n<pre><code>x = [,,]\nq = \nd = {: x}\n()\n()\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3974868%2F4dbd6443cb4e5c1dcb6091897dad5133%2FScreenshot%20from%202023-01-31%2022-33-18.png?generation=1675201181835483&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": "2124210",
      "postDate": "01/31/2023 21:43:58",
      "content": "<p>Hello!<br>\nwhile converting the pandas script to polars, I found a difference in the result of the <code>quantile()</code>. Given example pandas <code>quantile()</code> returns <code>1.2</code> while polars <code>1.0</code>. Any ideas what is going on?</p>\n<pre><code>x = [,,]\nq = \nd = {: x}\n()\n()\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3974868%2F4dbd6443cb4e5c1dcb6091897dad5133%2FScreenshot%20from%202023-01-31%2022-33-18.png?generation=1675201181835483&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Hello!\nwhile converting the pandas script to polars, I found a difference in the result of the `quantile()`. Given example pandas `quantile()` returns `1.2` while polars `1.0`. Any ideas what is going on?\n\n```python\nx = [1,2,3]\nq = .1\nd = {\"x\": x}\nprint(f'pandas quantile {pd.DataFrame(d).quantile(q)}')\nprint(f'polars quantile {pl.DataFrame(d).quantile(q)}')\n```\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3974868%2F4dbd6443cb4e5c1dcb6091897dad5133%2FScreenshot%20from%202023-01-31%2022-33-18.png?generation=1675201181835483&alt=media)",
      "votes": null
    },
    {
      "id": "2124253",
      "postDate": "01/31/2023 22:15:37",
      "content": "<p>You may have to set <code>interpolation='linear'</code> to match the pandas results. Polars uses nearest by default</p>",
      "rawMarkdown": "You may have to set `interpolation='linear'` to match the pandas results. Polars uses nearest by default",
      "votes": null
    },
    {
      "id": "2124262",
      "postDate": "01/31/2023 22:21:21",
      "content": "<p>I was looking for documentation <code>pl.quantile()</code> but can not find it.<br>\nWorks fine now, thanks <a href=\"https://www.kaggle.com/anjum48\" target=\"_blank\">@anjum48</a> !</p>",
      "rawMarkdown": "I was looking for documentation `pl.quantile()` but can not find it.\nWorks fine now, thanks @anjum48 !",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2124253,
      "author_name": "anjum48",
      "author_url": "",
      "post_date": "01/31/2023 22:15:37",
      "content": "<p>You may have to set <code>interpolation='linear'</code> to match the pandas results. Polars uses nearest by default</p>",
      "votes": null,
      "replies": [
        {
          "id": 2124262,
          "author_name": "wrrosa",
          "author_url": "",
          "post_date": "01/31/2023 22:21:21",
          "content": "<p>I was looking for documentation <code>pl.quantile()</code> but can not find it.<br>\nWorks fine now, thanks <a href=\"https://www.kaggle.com/anjum48\" target=\"_blank\">@anjum48</a> !</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2124210": "Hello!\nwhile converting the pandas script to polars, I found a difference in the result of the `quantile()`. Given example pandas `quantile()` returns `1.2` while polars `1.0`. Any ideas what is going on?\n\n```python\nx = [1,2,3]\nq = .1\nd = {\"x\": x}\nprint(f'pandas quantile {pd.DataFrame(d).quantile(q)}')\nprint(f'polars quantile {pl.DataFrame(d).quantile(q)}')\n```\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3974868%2F4dbd6443cb4e5c1dcb6091897dad5133%2FScreenshot%20from%202023-01-31%2022-33-18.png?generation=1675201181835483&alt=media)",
    "2124253": "You may have to set `interpolation='linear'` to match the pandas results. Polars uses nearest by default",
    "2124262": "I was looking for documentation `pl.quantile()` but can not find it.\nWorks fine now, thanks @anjum48 !"
  },
  "source": "meta"
}