{
  "id": 199309,
  "title": "How do you solve this error?",
  "url": "/competitions/riiid-test-answer-prediction/discussion/199309",
  "author_name": "kmkmks",
  "post_date": "2020-11-25T09:41:04.589000",
  "votes": 0,
  "comment_count": 5,
  "views": 0,
  "content": "<p>I got this error.<br>\n<code>NameError: name 'calc_mean' is not defined</code></p>\n<p>I run this code.<br>\n<code>user_df=train_df.groupby('user_id')</code><br>\n<code>calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})</code></p>",
  "messages": [
    {
      "id": 1090399,
      "postDate": "2020-11-25T10:04:02.440Z",
      "content": "<p>Hi! What's the aim of your code? The problem is that you didn't initialize calc_mean. Python can't interpret calc_mean['ac']. You can do calc_mean = code.</p>\n<p>Or you can intialize calc_mean as an empty object (like a dataframe), then your code should be ok.</p>",
      "rawMarkdown": "Hi! What's the aim of your code? The problem is that you didn't initialize calc_mean. Python can't interpret calc_mean['ac']. You can do calc_mean = code.\n\nOr you can intialize calc_mean as an empty object (like a dataframe), then your code should be ok.",
      "votes": 1,
      "replies": [
        {
          "id": 1090512,
          "postDate": "2020-11-25T11:41:05.250Z",
          "content": "<p>Hi! Thank you for comment.<br>\n my aim is that I put the mean of answered_correctly   into calc_mean and  name the column 'ac'<br>\nNext I was going to run this code.<br>\n<code>calc_mean['pqet']=user_df.agg({'prior_question_elapsed_time': ['mean']})</code></p>",
          "rawMarkdown": "Hi! Thank you for comment.\n my aim is that I put the mean of answered_correctly   into calc_mean and  name the column 'ac'\nNext I was going to run this code.\n`calc_mean['pqet']=user_df.agg({'prior_question_elapsed_time': ['mean']})`\n\n\n"
        },
        {
          "id": 1090524,
          "postDate": "2020-11-25T11:49:29.160Z",
          "content": "<p>In my opinion,When I ran calc_mean=code , the columns of calc_mean were not named </p>",
          "rawMarkdown": "In my opinion,When I ran calc_mean=code , the columns of calc_mean were not named "
        }
      ]
    },
    {
      "id": 1090369,
      "postDate": "2020-11-25T09:41:04.590Z",
      "content": "<p>I got this error.<br>\n<code>NameError: name 'calc_mean' is not defined</code></p>\n<p>I run this code.<br>\n<code>user_df=train_df.groupby('user_id')</code><br>\n<code>calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})</code></p>",
      "rawMarkdown": "I got this error.\n`NameError: name 'calc_mean' is not defined`\n\nI run this code.\n`user_df=train_df.groupby('user_id')`\n`calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})`"
    },
    {
      "id": 1091247,
      "postDate": "2020-11-25T22:21:05.830Z",
      "rawMarkdown": "",
      "votes": 1,
      "isDeleted": true,
      "replies": [
        {
          "id": 1091325,
          "postDate": "2020-11-26T00:08:44.947Z",
          "content": "<p>Hi! Narayan Thank you for comment!<br>\nI could understand my error and solve it! </p>\n<p>I made my own improvements and did this.<br>\n<code>calc_mean = pd.DataFrame({},index=calc_ac.index)</code><br>\n<code>calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})</code></p>",
          "rawMarkdown": "Hi! Narayan Thank you for comment!\nI could understand my error and solve it! \n\nI made my own improvements and did this.\n`calc_mean = pd.DataFrame({},index=calc_ac.index)`\n`calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})`"
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1090399,
      "author_name": "Edoardo Di Toma",
      "author_url": "",
      "post_date": "2020-11-25T10:04:02.440000",
      "content": "<p>Hi! What's the aim of your code? The problem is that you didn't initialize calc_mean. Python can't interpret calc_mean['ac']. You can do calc_mean = code.</p>\n<p>Or you can intialize calc_mean as an empty object (like a dataframe), then your code should be ok.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1090512,
          "author_name": "kmkmks",
          "author_url": "",
          "post_date": "2020-11-25T11:41:05.250000",
          "content": "<p>Hi! Thank you for comment.<br>\n my aim is that I put the mean of answered_correctly   into calc_mean and  name the column 'ac'<br>\nNext I was going to run this code.<br>\n<code>calc_mean['pqet']=user_df.agg({'prior_question_elapsed_time': ['mean']})</code></p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1090524,
          "author_name": "kmkmks",
          "author_url": "",
          "post_date": "2020-11-25T11:49:29.160000",
          "content": "<p>In my opinion,When I ran calc_mean=code , the columns of calc_mean were not named </p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1091247,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-11-25T22:21:05.830000",
      "content": "",
      "votes": 1,
      "replies": [
        {
          "id": 1091325,
          "author_name": "kmkmks",
          "author_url": "",
          "post_date": "2020-11-26T00:08:44.947000",
          "content": "<p>Hi! Narayan Thank you for comment!<br>\nI could understand my error and solve it! </p>\n<p>I made my own improvements and did this.<br>\n<code>calc_mean = pd.DataFrame({},index=calc_ac.index)</code><br>\n<code>calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})</code></p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1090399": "Hi! What's the aim of your code? The problem is that you didn't initialize calc_mean. Python can't interpret calc_mean['ac']. You can do calc_mean = code.\n\nOr you can intialize calc_mean as an empty object (like a dataframe), then your code should be ok.",
    "1090369": "I got this error.\n`NameError: name 'calc_mean' is not defined`\n\nI run this code.\n`user_df=train_df.groupby('user_id')`\n`calc_mean['ac']=user_df.agg({'answered_correctly': ['mean']})`",
    "1091247": ""
  }
}