{
  "id": 399871,
  "title": "Stuck on submission API",
  "url": "/competitions/predict-student-performance-from-game-play/discussion/399871",
  "author_name": "",
  "post_date": "2023-04-05T21:54:59.546330900Z",
  "votes": null,
  "comment_count": 3,
  "views": 0,
  "content": "<p>Hi,</p>\n<p>I have the folowing code when calling up the submission API</p>\n<p>for (sample_submission, test) in iter_test:<br>\n    df_test['session_id', 'text_fqid', 'level']  = test.loc[:,[\"session_id\", \"text_fqid\",\"level\"]]</p>\n<p>but I end up getting this error:</p>\n<p>KeyError: \"['text_fqid', 'level'] not in index\"</p>\n<p>Why do these columns not exist in the \"test\" dataframe? </p>\n<p>and is there a simple guide as to how to submit predictions using the API? All the tutorials had a submission via a .csv file and this was much easier.<br>\nThanks</p>",
  "messages": [
    {
      "id": "2211196",
      "postDate": "04/05/2023 21:54:59",
      "content": "<p>Hi,</p>\n<p>I have the folowing code when calling up the submission API</p>\n<p>for (sample_submission, test) in iter_test:<br>\n    df_test['session_id', 'text_fqid', 'level']  = test.loc[:,[\"session_id\", \"text_fqid\",\"level\"]]</p>\n<p>but I end up getting this error:</p>\n<p>KeyError: \"['text_fqid', 'level'] not in index\"</p>\n<p>Why do these columns not exist in the \"test\" dataframe? </p>\n<p>and is there a simple guide as to how to submit predictions using the API? All the tutorials had a submission via a .csv file and this was much easier.<br>\nThanks</p>",
      "rawMarkdown": "Hi,\n\nI have the folowing code when calling up the submission API\n\nfor (sample_submission, test) in iter_test:\n    df_test['session_id', 'text_fqid', 'level']  = test.loc[:,[\"session_id\", \"text_fqid\",\"level\"]]\n\nbut I end up getting this error:\n\nKeyError: \"['text_fqid', 'level'] not in index\"\n\nWhy do these columns not exist in the \"test\" dataframe? \n\nand is there a simple guide as to how to submit predictions using the API? All the tutorials had a submission via a .csv file and this was much easier.\nThanks",
      "votes": null
    },
    {
      "id": "2211197",
      "postDate": "04/05/2023 21:59:04",
      "content": "<p>Change the order in the for loop:</p>\n<p><code>for (test, sample_submission) in iter_test:</code></p>\n<p>See comment by <a href=\"https://www.kaggle.com/AT\" target=\"_blank\">@AT</a> in [<a href=\"https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396202\" target=\"_blank\">https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396202</a>]</p>",
      "rawMarkdown": "Change the order in the for loop:\n\n`for (test, sample_submission) in iter_test:`\n\nSee comment by @AT in [https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396202]",
      "votes": null
    },
    {
      "id": "2211738",
      "postDate": "04/06/2023 08:22:36",
      "content": "<p>Thanks - it did sort of work….</p>\n<p>then I realized that the API just includes levels 0-4, so only the first set of questions - is this expected?</p>\n<p>(so sample_submission only had 9 rows)</p>\n<p>Then when I modified my code to just include the first set of questions- I got the following error when it enters the for loop:<br>\nfor (test, sample_submission) in iter_test:<br>\n TypeError: cannot unpack non-iterable NoneType object</p>\n<p>Is this related to the above, as in the API doesn't contain all the data?</p>",
      "rawMarkdown": "Thanks - it did sort of work....\n\n then I realized that the API just includes levels 0-4, so only the first set of questions - is this expected?\n\n(so sample_submission only had 9 rows)\n\nThen when I modified my code to just include the first set of questions- I got the following error when it enters the for loop:\nfor (test, sample_submission) in iter_test:\n TypeError: cannot unpack non-iterable NoneType object\n\nIs this related to the above, as in the API doesn't contain all the data?",
      "votes": null
    },
    {
      "id": "2212035",
      "postDate": "04/06/2023 13:16:50",
      "content": "<p>That has to do with the API, you can only instantiate it once.  Try to restart the entire notebook and run from the beginning.</p>",
      "rawMarkdown": "That has to do with the API, you can only instantiate it once.  Try to restart the entire notebook and run from the beginning.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2211197,
      "author_name": "danielphalen",
      "author_url": "",
      "post_date": "04/05/2023 21:59:04",
      "content": "<p>Change the order in the for loop:</p>\n<p><code>for (test, sample_submission) in iter_test:</code></p>\n<p>See comment by <a href=\"https://www.kaggle.com/AT\" target=\"_blank\">@AT</a> in [<a href=\"https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396202\" target=\"_blank\">https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396202</a>]</p>",
      "votes": null,
      "replies": [
        {
          "id": 2211738,
          "author_name": "dansteveroberts",
          "author_url": "",
          "post_date": "04/06/2023 08:22:36",
          "content": "<p>Thanks - it did sort of work….</p>\n<p>then I realized that the API just includes levels 0-4, so only the first set of questions - is this expected?</p>\n<p>(so sample_submission only had 9 rows)</p>\n<p>Then when I modified my code to just include the first set of questions- I got the following error when it enters the for loop:<br>\nfor (test, sample_submission) in iter_test:<br>\n TypeError: cannot unpack non-iterable NoneType object</p>\n<p>Is this related to the above, as in the API doesn't contain all the data?</p>",
          "votes": null,
          "replies": [
            {
              "id": 2212035,
              "author_name": "danielphalen",
              "author_url": "",
              "post_date": "04/06/2023 13:16:50",
              "content": "<p>That has to do with the API, you can only instantiate it once.  Try to restart the entire notebook and run from the beginning.</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2211196": "Hi,\n\nI have the folowing code when calling up the submission API\n\nfor (sample_submission, test) in iter_test:\n    df_test['session_id', 'text_fqid', 'level']  = test.loc[:,[\"session_id\", \"text_fqid\",\"level\"]]\n\nbut I end up getting this error:\n\nKeyError: \"['text_fqid', 'level'] not in index\"\n\nWhy do these columns not exist in the \"test\" dataframe? \n\nand is there a simple guide as to how to submit predictions using the API? All the tutorials had a submission via a .csv file and this was much easier.\nThanks",
    "2211197": "Change the order in the for loop:\n\n`for (test, sample_submission) in iter_test:`\n\nSee comment by @AT in [https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396202]",
    "2211738": "Thanks - it did sort of work....\n\n then I realized that the API just includes levels 0-4, so only the first set of questions - is this expected?\n\n(so sample_submission only had 9 rows)\n\nThen when I modified my code to just include the first set of questions- I got the following error when it enters the for loop:\nfor (test, sample_submission) in iter_test:\n TypeError: cannot unpack non-iterable NoneType object\n\nIs this related to the above, as in the API doesn't contain all the data?",
    "2212035": "That has to do with the API, you can only instantiate it once.  Try to restart the entire notebook and run from the beginning."
  },
  "source": "meta"
}