{
  "id": 498258,
  "title": "Polars issue",
  "url": "/competitions/home-credit-credit-risk-model-stability/discussion/498258",
  "author_name": "",
  "post_date": "2024-04-27T14:18:03.136734800Z",
  "votes": 2,
  "comment_count": 1,
  "views": 0,
  "content": "<p>I have a question that I haven't found an effective solution yet. Although Pandas can be used, I still hope to obtain the current case_id in the custom expr when aggregating aggs by grouping data according to case_id using polars? <br>\nFor example:<br>\ndef udf_func(x1,x2):<br>\n      #How to obtain the value of case_id for the current group in udf_func?</p>\n<p>df. group_by ('case_id '). agg (udf_func (x1, x2))<br>\nIf someone could provide insights, that would be very grateful.🔥</p>",
  "messages": [
    {
      "id": "2779112",
      "postDate": "04/27/2024 14:18:03",
      "content": "<p>I have a question that I haven't found an effective solution yet. Although Pandas can be used, I still hope to obtain the current case_id in the custom expr when aggregating aggs by grouping data according to case_id using polars? <br>\nFor example:<br>\ndef udf_func(x1,x2):<br>\n      #How to obtain the value of case_id for the current group in udf_func?</p>\n<p>df. group_by ('case_id '). agg (udf_func (x1, x2))<br>\nIf someone could provide insights, that would be very grateful.🔥</p>",
      "rawMarkdown": "I have a question that I haven't found an effective solution yet. Although Pandas can be used, I still hope to obtain the current case_id in the custom expr when aggregating aggs by grouping data according to case_id using polars? \nFor example:\ndef udf_func(x1,x2):\n      #How to obtain the value of case_id for the current group in udf_func?\n\ndf. group_by ('case_id '). agg (udf_func (x1, x2))\nIf someone could provide insights, that would be very grateful.🔥",
      "votes": null
    },
    {
      "id": "2783078",
      "postDate": "04/29/2024 15:04:57",
      "content": "<p>Can try: </p>\n<pre><code> ():\n    case_id = pl.first()  \n</code></pre>",
      "rawMarkdown": "Can try: \n```\ndef udf_func(x1, x2):\n    case_id = pl.first('case_id')  # Obtain the value of case_id for the current group\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2783078,
      "author_name": "faithk7u",
      "author_url": "",
      "post_date": "04/29/2024 15:04:57",
      "content": "<p>Can try: </p>\n<pre><code> ():\n    case_id = pl.first()  \n</code></pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2779112": "I have a question that I haven't found an effective solution yet. Although Pandas can be used, I still hope to obtain the current case_id in the custom expr when aggregating aggs by grouping data according to case_id using polars? \nFor example:\ndef udf_func(x1,x2):\n      #How to obtain the value of case_id for the current group in udf_func?\n\ndf. group_by ('case_id '). agg (udf_func (x1, x2))\nIf someone could provide insights, that would be very grateful.🔥",
    "2783078": "Can try: \n```\ndef udf_func(x1, x2):\n    case_id = pl.first('case_id')  # Obtain the value of case_id for the current group\n```"
  },
  "source": "meta"
}