{
  "id": 116401,
  "title": "Use holidays as a feature",
  "url": "/competitions/ashrae-energy-prediction/discussion/116401",
  "author_name": "Haythem Tellili",
  "post_date": "2019-11-08T21:09:27.212000",
  "votes": 4,
  "comment_count": 0,
  "views": 0,
  "content": "<p>The feature is simply computed as follows:\n<code>us_holidays = holidays.UnitedStates()  # take US holidays</code></p>\n\n<p>and then compute a binary holidays feature based on previously converted date time:</p>\n\n<p>```</p>\n\n<p>def isholiday(x):\n     return int(x in us_holidays)\ntrain['holiday'] = train['pickup_datetime'].apply(isholiday)\ntest['holiday'] = test['pickup_datetime'].apply(isholiday)\n```</p>",
  "messages": [
    {
      "id": 668789,
      "postDate": "2019-11-08T21:09:27.213Z",
      "content": "<p>The feature is simply computed as follows:\n<code>us_holidays = holidays.UnitedStates()  # take US holidays</code></p>\n\n<p>and then compute a binary holidays feature based on previously converted date time:</p>\n\n<p>```</p>\n\n<p>def isholiday(x):\n     return int(x in us_holidays)\ntrain['holiday'] = train['pickup_datetime'].apply(isholiday)\ntest['holiday'] = test['pickup_datetime'].apply(isholiday)\n```</p>",
      "rawMarkdown": "The feature is simply computed as follows:\n`us_holidays = holidays.UnitedStates()  # take US holidays`\n\n\nand then compute a binary holidays feature based on previously converted date time:\n\n```\n\ndef isholiday(x):\n     return int(x in us_holidays)\ntrain['holiday'] = train['pickup_datetime'].apply(isholiday)\ntest['holiday'] = test['pickup_datetime'].apply(isholiday)\n```\n",
      "votes": 4
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "668789": "The feature is simply computed as follows:\n`us_holidays = holidays.UnitedStates()  # take US holidays`\n\n\nand then compute a binary holidays feature based on previously converted date time:\n\n```\n\ndef isholiday(x):\n     return int(x in us_holidays)\ntrain['holiday'] = train['pickup_datetime'].apply(isholiday)\ntest['holiday'] = test['pickup_datetime'].apply(isholiday)\n```\n"
  }
}