{
  "id": 335540,
  "title": "最頻値について(About mode)",
  "url": "/competitions/amex-default-prediction/discussion/335540",
  "author_name": "",
  "post_date": "2022-07-06T17:22:30.050239500Z",
  "votes": null,
  "comment_count": 7,
  "views": 0,
  "content": "<p>I tried to calculate the mode of the category variable column for each customer ID with the following code, but the calculation time was too long and I got frustrated.</p>\n<p>df.groupby('cutomer_ID').apply(lambda x: x.mode())</p>\n<p>I am very sorry, but I would appreciate your advice.</p>\n<p>カスタマーIDごとのカテゴリ変数カラムの最頻値を算出するために、下記コードで算出しようとしたところ計算時間が長すぎて挫折しました。</p>\n<p>df.groupby('cutomer_ID').apply(lambda x: x.mode())</p>\n<p>大変恐縮ですが、アドバイスいただけますと幸いです。</p>",
  "messages": [
    {
      "id": "1845928",
      "postDate": "07/06/2022 17:22:30",
      "content": "<p>I tried to calculate the mode of the category variable column for each customer ID with the following code, but the calculation time was too long and I got frustrated.</p>\n<p>df.groupby('cutomer_ID').apply(lambda x: x.mode())</p>\n<p>I am very sorry, but I would appreciate your advice.</p>\n<p>カスタマーIDごとのカテゴリ変数カラムの最頻値を算出するために、下記コードで算出しようとしたところ計算時間が長すぎて挫折しました。</p>\n<p>df.groupby('cutomer_ID').apply(lambda x: x.mode())</p>\n<p>大変恐縮ですが、アドバイスいただけますと幸いです。</p>",
      "rawMarkdown": "I tried to calculate the mode of the category variable column for each customer ID with the following code, but the calculation time was too long and I got frustrated.\n\ndf.groupby('cutomer_ID').apply(lambda x: x.mode())\n\nI am very sorry, but I would appreciate your advice.\n\nカスタマーIDごとのカテゴリ変数カラムの最頻値を算出するために、下記コードで算出しようとしたところ計算時間が長すぎて挫折しました。\n\ndf.groupby('cutomer_ID').apply(lambda x: x.mode())\n\n大変恐縮ですが、アドバイスいただけますと幸いです。",
      "votes": null
    },
    {
      "id": "1846024",
      "postDate": "07/06/2022 18:52:29",
      "content": "<p>mode function is computationally intensive. Try <code>scipy.stats.mode</code> - it may be better optimized</p>",
      "rawMarkdown": "mode function is computationally intensive. Try `scipy.stats.mode` - it may be better optimized",
      "votes": null
    },
    {
      "id": "1846557",
      "postDate": "07/07/2022 06:53:19",
      "content": "<p>I tried the method you taught me and <code>pandas.Series.mode.</code> I am very happy that I got the desired features.<br>\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。</p>",
      "rawMarkdown": "I tried the method you taught me and `pandas.Series.mode.` I am very happy that I got the desired features.\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。",
      "votes": null
    },
    {
      "id": "1847846",
      "postDate": "07/08/2022 07:48:11",
      "content": "<p>私はこの方法を試してみました。errorになつた。成功の方法教えてくれましか？</p>",
      "rawMarkdown": "私はこの方法を試してみました。errorになつた。成功の方法教えてくれましか？",
      "votes": null
    },
    {
      "id": "1848013",
      "postDate": "07/08/2022 09:55:46",
      "content": "<p>I will share my code with you.<br>\nI hope it will be helpful.<br>\nEnjoy the competition!</p>\n<p><code>!pip install scipy update</code><br>\n<code>from scipy import stats</code><br>\n<code>train.groupby(\"customer_ID\")[cat_features].agg(lambda x: stats.mode(x)[0])</code></p>\n<p>私のコードを紹介します。<br>\n参考になれば幸いです。<br>\nコンペを楽しみましょう！</p>",
      "rawMarkdown": "I will share my code with you.\nI hope it will be helpful.\nEnjoy the competition!\n\n`!pip install scipy update`\n`from scipy import stats`\n`train.groupby(\"customer_ID\")[cat_features].agg(lambda x: stats.mode(x)[0])`\n\n私のコードを紹介します。\n参考になれば幸いです。\nコンペを楽しみましょう！",
      "votes": null
    },
    {
      "id": "1848823",
      "postDate": "07/08/2022 23:53:20",
      "content": "<p>私はcudf条件下で運転しているので、エラーを報告します。</p>\n<p>TypeError: Cannot convert numpy.ndarray to cudf._lib.aggregation.GroupbyAggregation</p>\n<p>train.to_pandas()後は実行することができますが、遅くなります。あなたはcudfを使っていますか。</p>",
      "rawMarkdown": "私はcudf条件下で運転しているので、エラーを報告します。\n\nTypeError: Cannot convert numpy.ndarray to cudf._lib.aggregation.GroupbyAggregation\n\ntrain.to_pandas()後は実行することができますが、遅くなります。あなたはcudfを使っていますか。",
      "votes": null
    },
    {
      "id": "1849354",
      "postDate": "07/09/2022 12:49:13",
      "content": "<p>I am using pandas.<br>\nI have never used cudf and do not know how to solve this problem.<br>\nI am very sorry that I cannot help you.<br>\nIf you know how to solve the error, I would appreciate your comments.</p>\n<p>私はpandasを使っています。<br>\ncudfは使ったことがなく、解決方法がわかりません。<br>\nお力になれず、大変申し訳ございません。<br>\nエラーの解決方法をご存知の方、コメントいただけると幸いです。</p>",
      "rawMarkdown": "I am using pandas.\nI have never used cudf and do not know how to solve this problem.\nI am very sorry that I cannot help you.\nIf you know how to solve the error, I would appreciate your comments.\n\n私はpandasを使っています。\ncudfは使ったことがなく、解決方法がわかりません。\nお力になれず、大変申し訳ございません。\nエラーの解決方法をご存知の方、コメントいただけると幸いです。",
      "votes": null
    },
    {
      "id": "1849399",
      "postDate": "07/09/2022 13:24:23",
      "content": "<p>I learned how to use REPLY！</p>\n<p>I tried the method you taught me and pandas.Series.mode. I am very happy that I got the desired features.<br>\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。</p>",
      "rawMarkdown": "I learned how to use REPLY！\n\nI tried the method you taught me and pandas.Series.mode. I am very happy that I got the desired features.\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1846024,
      "author_name": "raddar",
      "author_url": "",
      "post_date": "07/06/2022 18:52:29",
      "content": "<p>mode function is computationally intensive. Try <code>scipy.stats.mode</code> - it may be better optimized</p>",
      "votes": null,
      "replies": [
        {
          "id": 1849399,
          "author_name": "miyawakiyoshifumi",
          "author_url": "",
          "post_date": "07/09/2022 13:24:23",
          "content": "<p>I learned how to use REPLY！</p>\n<p>I tried the method you taught me and pandas.Series.mode. I am very happy that I got the desired features.<br>\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1846557,
      "author_name": "miyawakiyoshifumi",
      "author_url": "",
      "post_date": "07/07/2022 06:53:19",
      "content": "<p>I tried the method you taught me and <code>pandas.Series.mode.</code> I am very happy that I got the desired features.<br>\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1847846,
      "author_name": "hazlitt",
      "author_url": "",
      "post_date": "07/08/2022 07:48:11",
      "content": "<p>私はこの方法を試してみました。errorになつた。成功の方法教えてくれましか？</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1848013,
      "author_name": "miyawakiyoshifumi",
      "author_url": "",
      "post_date": "07/08/2022 09:55:46",
      "content": "<p>I will share my code with you.<br>\nI hope it will be helpful.<br>\nEnjoy the competition!</p>\n<p><code>!pip install scipy update</code><br>\n<code>from scipy import stats</code><br>\n<code>train.groupby(\"customer_ID\")[cat_features].agg(lambda x: stats.mode(x)[0])</code></p>\n<p>私のコードを紹介します。<br>\n参考になれば幸いです。<br>\nコンペを楽しみましょう！</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1848823,
      "author_name": "hazlitt",
      "author_url": "",
      "post_date": "07/08/2022 23:53:20",
      "content": "<p>私はcudf条件下で運転しているので、エラーを報告します。</p>\n<p>TypeError: Cannot convert numpy.ndarray to cudf._lib.aggregation.GroupbyAggregation</p>\n<p>train.to_pandas()後は実行することができますが、遅くなります。あなたはcudfを使っていますか。</p>",
      "votes": null,
      "replies": [
        {
          "id": 1849354,
          "author_name": "miyawakiyoshifumi",
          "author_url": "",
          "post_date": "07/09/2022 12:49:13",
          "content": "<p>I am using pandas.<br>\nI have never used cudf and do not know how to solve this problem.<br>\nI am very sorry that I cannot help you.<br>\nIf you know how to solve the error, I would appreciate your comments.</p>\n<p>私はpandasを使っています。<br>\ncudfは使ったことがなく、解決方法がわかりません。<br>\nお力になれず、大変申し訳ございません。<br>\nエラーの解決方法をご存知の方、コメントいただけると幸いです。</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1845928": "I tried to calculate the mode of the category variable column for each customer ID with the following code, but the calculation time was too long and I got frustrated.\n\ndf.groupby('cutomer_ID').apply(lambda x: x.mode())\n\nI am very sorry, but I would appreciate your advice.\n\nカスタマーIDごとのカテゴリ変数カラムの最頻値を算出するために、下記コードで算出しようとしたところ計算時間が長すぎて挫折しました。\n\ndf.groupby('cutomer_ID').apply(lambda x: x.mode())\n\n大変恐縮ですが、アドバイスいただけますと幸いです。",
    "1846024": "mode function is computationally intensive. Try `scipy.stats.mode` - it may be better optimized",
    "1846557": "I tried the method you taught me and `pandas.Series.mode.` I am very happy that I got the desired features.\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。",
    "1847846": "私はこの方法を試してみました。errorになつた。成功の方法教えてくれましか？",
    "1848013": "I will share my code with you.\nI hope it will be helpful.\nEnjoy the competition!\n\n`!pip install scipy update`\n`from scipy import stats`\n`train.groupby(\"customer_ID\")[cat_features].agg(lambda x: stats.mode(x)[0])`\n\n私のコードを紹介します。\n参考になれば幸いです。\nコンペを楽しみましょう！",
    "1848823": "私はcudf条件下で運転しているので、エラーを報告します。\n\nTypeError: Cannot convert numpy.ndarray to cudf._lib.aggregation.GroupbyAggregation\n\ntrain.to_pandas()後は実行することができますが、遅くなります。あなたはcudfを使っていますか。",
    "1849354": "I am using pandas.\nI have never used cudf and do not know how to solve this problem.\nI am very sorry that I cannot help you.\nIf you know how to solve the error, I would appreciate your comments.\n\n私はpandasを使っています。\ncudfは使ったことがなく、解決方法がわかりません。\nお力になれず、大変申し訳ございません。\nエラーの解決方法をご存知の方、コメントいただけると幸いです。",
    "1849399": "I learned how to use REPLY！\n\nI tried the method you taught me and pandas.Series.mode. I am very happy that I got the desired features.\nThank you very kindly.教えていただいた方法とpandas.Series.modeを試してみました。目的の特徴量を作成することができ、大変満足しています。親切にありがとうございました。"
  },
  "source": "meta"
}