{
  "id": 285291,
  "title": "A Faster Way to Load Data",
  "url": "/competitions/g-research-crypto-forecasting/discussion/285291",
  "author_name": "",
  "post_date": "2021-11-04T04:20:49.256934100Z",
  "votes": 27,
  "comment_count": 19,
  "views": 0,
  "content": "<p>Since the data provided for the competition is relatively large, loading it as <code>pd.read_csv</code> takes extremely long (around 1 minute and 10 seconds). However, converting the data into <code>.jay</code> files speeds up the process by a lot (about 19 seconds).</p>\n<pre><code># Converting to Jay Files\nimport pandas as pd\ntrain = pd.read_csv(\"../input/g-research-crypto-forecasting/train.csv\")\nimport datatable as dt\ndt.Frame(train).to_jay(\"g_research_crypto_forecasting.jay\")\n</code></pre>\n<p>Once converted to Jay files, read in the data as follow</p>\n<pre><code>import datatable as dt\ndata = dt.fread(\"../input/g-research-train-in-jay-format/g_research_crypto_forecasting.jay\").to_pandas()\n#Gives you a Pandas DataFrame\n</code></pre>\n<p>I hope this method can speed up your data reading process without having to wait for a whole minute just to read in the data.<br>\nDoes anyone know other ways that can read the data faster? (19 seconds is still pretty slow 😂 I've tried Pickle and Feather)</p>",
  "messages": [
    {
      "id": "1570343",
      "postDate": "11/04/2021 04:20:49",
      "content": "<p>Since the data provided for the competition is relatively large, loading it as <code>pd.read_csv</code> takes extremely long (around 1 minute and 10 seconds). However, converting the data into <code>.jay</code> files speeds up the process by a lot (about 19 seconds).</p>\n<pre><code># Converting to Jay Files\nimport pandas as pd\ntrain = pd.read_csv(\"../input/g-research-crypto-forecasting/train.csv\")\nimport datatable as dt\ndt.Frame(train).to_jay(\"g_research_crypto_forecasting.jay\")\n</code></pre>\n<p>Once converted to Jay files, read in the data as follow</p>\n<pre><code>import datatable as dt\ndata = dt.fread(\"../input/g-research-train-in-jay-format/g_research_crypto_forecasting.jay\").to_pandas()\n#Gives you a Pandas DataFrame\n</code></pre>\n<p>I hope this method can speed up your data reading process without having to wait for a whole minute just to read in the data.<br>\nDoes anyone know other ways that can read the data faster? (19 seconds is still pretty slow 😂 I've tried Pickle and Feather)</p>",
      "rawMarkdown": "Since the data provided for the competition is relatively large, loading it as `pd.read_csv` takes extremely long (around 1 minute and 10 seconds). However, converting the data into `.jay` files speeds up the process by a lot (about 19 seconds).\n```\n# Converting to Jay Files\nimport pandas as pd\ntrain = pd.read_csv(\"../input/g-research-crypto-forecasting/train.csv\")\nimport datatable as dt\ndt.Frame(train).to_jay(\"g_research_crypto_forecasting.jay\")\n```\nOnce converted to Jay files, read in the data as follow\n```\nimport datatable as dt\ndata = dt.fread(\"../input/g-research-train-in-jay-format/g_research_crypto_forecasting.jay\").to_pandas()\n#Gives you a Pandas DataFrame\n```\nI hope this method can speed up your data reading process without having to wait for a whole minute just to read in the data.\nDoes anyone know other ways that can read the data faster? (19 seconds is still pretty slow 😂 I've tried Pickle and Feather)",
      "votes": null
    },
    {
      "id": "1570401",
      "postDate": "11/04/2021 05:43:30",
      "content": "<p>Dear <a href=\"https://www.kaggle.com/andy1010\" target=\"_blank\">@andy1010</a> </p>\n<p>May I heartily recommend  the <a href=\"https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets\" target=\"_blank\">\"Tutorial on reading large datasets\"</a> written by <a href=\"https://www.kaggle.com/rohanrao\" target=\"_blank\">Vopani</a>, introducing alternatives such as Dask, Datatable and the the Rapids <code>cudf</code>, which harnesses the power of the GPU's, and all affording considerable speedups w.r.t. pandas.  </p>\n<p>All the best,<br>\ncarl</p>",
      "rawMarkdown": "Dear @andy1010 \n\n May I heartily recommend  the [\"Tutorial on reading large datasets\"](https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets) written by [Vopani](https://www.kaggle.com/rohanrao), introducing alternatives such as Dask, Datatable and the the Rapids `cudf`, which harnesses the power of the GPU's, and all affording considerable speedups w.r.t. pandas.  \n\nAll the best,\ncarl",
      "votes": null
    },
    {
      "id": "1570595",
      "postDate": "11/04/2021 08:53:36",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/andy1010\" target=\"_blank\">@andy1010</a> </p>\n<p>This might help. <br>\n<a href=\"https://www.kaggle.com/pedrocouto39/fast-reading-w-pickle-feather-parquet-jay\" target=\"_blank\">https://www.kaggle.com/pedrocouto39/fast-reading-w-pickle-feather-parquet-jay</a><br>\n<a href=\"https://www.kaggle.com/c/jane-street-market-prediction/discussion/199233\" target=\"_blank\">https://www.kaggle.com/c/jane-street-market-prediction/discussion/199233</a><br>\n<a href=\"https://www.kaggle.com/pedrocouto39/jane-street-market-train-data-best-formats\" target=\"_blank\">https://www.kaggle.com/pedrocouto39/jane-street-market-train-data-best-formats</a></p>",
      "rawMarkdown": "Hi @andy1010 \n\nThis might help. \nhttps://www.kaggle.com/pedrocouto39/fast-reading-w-pickle-feather-parquet-jay\nhttps://www.kaggle.com/c/jane-street-market-prediction/discussion/199233\nhttps://www.kaggle.com/pedrocouto39/jane-street-market-train-data-best-formats",
      "votes": null
    },
    {
      "id": "1570748",
      "postDate": "11/04/2021 10:49:34",
      "content": "<p>wow, jay seems super fast. Thanks for the links <a href=\"https://www.kaggle.com/faisalalsrheed\" target=\"_blank\">@faisalalsrheed</a> </p>",
      "rawMarkdown": "wow, jay seems super fast. Thanks for the links @faisalalsrheed",
      "votes": null
    },
    {
      "id": "1570764",
      "postDate": "11/04/2021 11:02:55",
      "content": "<p>Already read that notebook, but still the best in this topic. Thanks <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> </p>",
      "rawMarkdown": "Already read that notebook, but still the best in this topic. Thanks @carlmcbrideellis",
      "votes": null
    },
    {
      "id": "1570832",
      "postDate": "11/04/2021 12:09:26",
      "content": "<p>Alright, this question made me curious and I had to try. I made a notebook with the suggestions from: <a href=\"https://www.kaggle.com/faisalalsrheed\" target=\"_blank\">@faisalalsrheed</a> and <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> using the training data from the competition: <a href=\"https://www.kaggle.com/ajpass/reading-speed-comparation-between-file-formats\" target=\"_blank\">https://www.kaggle.com/ajpass/reading-speed-comparation-between-file-formats</a> . Hope it helps you :D</p>\n<p>Abstract: Jay format is the fastest but uses a library called datatable which doesn't have a very exhaustive set of data processing functions (as said in <a href=\"https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets)\" target=\"_blank\">https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets)</a>.</p>\n<p>P.S.: I also added all the advice given by <a href=\"https://www.kaggle.com/jpmiller\" target=\"_blank\">@jpmiller</a> which I think it's fantastic. </p>",
      "rawMarkdown": "Alright, this question made me curious and I had to try. I made a notebook with the suggestions from: @faisalalsrheed and @carlmcbrideellis using the training data from the competition: https://www.kaggle.com/ajpass/reading-speed-comparation-between-file-formats . Hope it helps you :D\n\nAbstract: Jay format is the fastest but uses a library called datatable which doesn't have a very exhaustive set of data processing functions (as said in https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets).\n\nP.S.: I also added all the advice given by @jpmiller which I think it's fantastic.",
      "votes": null
    },
    {
      "id": "1570849",
      "postDate": "11/04/2021 12:30:34",
      "content": "<p>You might want to build a smaller data set for debugging purposes. </p>",
      "rawMarkdown": "You might want to build a smaller data set for debugging purposes.",
      "votes": null
    },
    {
      "id": "1570995",
      "postDate": "11/04/2021 14:34:45",
      "content": "<p>I'm not sure where you getting 19sec from, but your method is pretty fast for me, thanks!</p>\n<p>stats from kaggle cpu kernel:</p>\n<p>%%time<br>\ndata_folder = \"../input/g-research-crypto-forecasting/\"<br>\ndata_folder2 = \"../input/gresearch-crypto-forcasting-train/\"<br>\n​<br>\nasset_details = pd.read_csv(data_folder + 'asset_details.csv')<br>\ncrypto_df = dt.fread(data_folder2 + \"train.jay\").to_pandas()</p>\n<p>CPU times: user 908 ms, sys: 490 ms, total: 1.4 s<br>\nWall time: 987 ms</p>",
      "rawMarkdown": "I'm not sure where you getting 19sec from, but your method is pretty fast for me, thanks!\n\nstats from kaggle cpu kernel:\n\n%%time\ndata_folder = \"../input/g-research-crypto-forecasting/\"\ndata_folder2 = \"../input/gresearch-crypto-forcasting-train/\"\n​\nasset_details = pd.read_csv(data_folder + 'asset_details.csv')\ncrypto_df = dt.fread(data_folder2 + \"train.jay\").to_pandas()\n\nCPU times: user 908 ms, sys: 490 ms, total: 1.4 s\nWall time: 987 ms",
      "votes": null
    },
    {
      "id": "1571044",
      "postDate": "11/04/2021 14:57:28",
      "content": "<p>Hmm, that's quite interesting. For me, reading in the data only takes about 25 milliseconds, however the conversion to pandas takes 15~ seconds. </p>",
      "rawMarkdown": "Hmm, that's quite interesting. For me, reading in the data only takes about 25 milliseconds, however the conversion to pandas takes 15~ seconds.",
      "votes": null
    },
    {
      "id": "1571046",
      "postDate": "11/04/2021 14:57:56",
      "content": "<p>Thanks for the nice notebook, very helpful resource!</p>",
      "rawMarkdown": "Thanks for the nice notebook, very helpful resource!",
      "votes": null
    },
    {
      "id": "1571052",
      "postDate": "11/04/2021 14:59:49",
      "content": "<p>Yes, I did get similar results using other data formats and Jay was the fastest. However, the process that's taking the longest for me is converting to pandas DataFrame since as mentioned, datatable does not have a very wide range of data processing functions. Thanks for the help anyways!</p>",
      "rawMarkdown": "Yes, I did get similar results using other data formats and Jay was the fastest. However, the process that's taking the longest for me is converting to pandas DataFrame since as mentioned, datatable does not have a very wide range of data processing functions. Thanks for the help anyways!",
      "votes": null
    },
    {
      "id": "1571787",
      "postDate": "11/05/2021 06:48:55",
      "content": "<p>Using pickle is also a good way.</p>",
      "rawMarkdown": "Using pickle is also a good way.",
      "votes": null
    },
    {
      "id": "1572190",
      "postDate": "11/05/2021 13:46:24",
      "content": "<p>Just putting it out there… <br>\nvroom package in R: 12.562 seconds</p>",
      "rawMarkdown": "Just putting it out there... \nvroom package in R: 12.562 seconds",
      "votes": null
    },
    {
      "id": "1572852",
      "postDate": "11/06/2021 03:19:25",
      "content": "<p>You might try flipping the operations here.</p>\n<ul>\n<li>Use datatable to read in the csv and convert to pandas (much faster than a <code>pd.read_csv()</code>)</li>\n<li>Do your thing with the data in pandas</li>\n<li>Save the file back as <code>pd.to_parquet()</code> or feather, hd5</li>\n</ul>",
      "rawMarkdown": "You might try flipping the operations here.\n- Use datatable to read in the csv and convert to pandas (much faster than a `pd.read_csv()`)\n- Do your thing with the data in pandas\n- Save the file back as `pd.to_parquet()` or feather, hd5",
      "votes": null
    },
    {
      "id": "1572864",
      "postDate": "11/06/2021 03:30:40",
      "content": "<p>Pickle is easy, versatile and fine for personal use. There may be issues though in more general applications.</p>\n<ul>\n<li><a href=\"https://www.benfrederickson.com/dont-pickle-your-data/\" target=\"_blank\">https://www.benfrederickson.com/dont-pickle-your-data/</a></li>\n<li><a href=\"https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html\" target=\"_blank\">https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html</a></li>\n</ul>",
      "rawMarkdown": "Pickle is easy, versatile and fine for personal use. There may be issues though in more general applications.\n- https://www.benfrederickson.com/dont-pickle-your-data/\n- https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html",
      "votes": null
    },
    {
      "id": "1572874",
      "postDate": "11/06/2021 03:41:26",
      "content": "<p>Thanks for reminding ! 👍</p>",
      "rawMarkdown": "Thanks for reminding ! 👍",
      "votes": null
    },
    {
      "id": "1573111",
      "postDate": "11/06/2021 09:32:46",
      "content": "<p>Thank you so much for taking your time for making this post. Also, When pd.read_csv take 1 minute 19s for me, jay made it in 2 seconds. Insane difference.</p>",
      "rawMarkdown": "Thank you so much for taking your time for making this post. Also, When pd.read_csv take 1 minute 19s for me, jay made it in 2 seconds. Insane difference.",
      "votes": null
    },
    {
      "id": "1573200",
      "postDate": "11/06/2021 11:44:27",
      "content": "<p>Don't know why i didn't think about that, nice point <a href=\"https://www.kaggle.com/jpmiller\" target=\"_blank\">@jpmiller</a> </p>\n<p>As suggested:</p>\n<ul>\n<li>Install datatable: ~9seconds</li>\n<li>csvDT = dt.fread(mainFolder + 'train.csv'):  ~9 seconds</li>\n<li>df = csvDT.to_pandas(): ~2 seconds </li>\n</ul>\n<p>Good advice, I will read data this way for my next notebook.</p>\n<p><a href=\"https://www.kaggle.com/andy1010\" target=\"_blank\">@andy1010</a> you can check this page for a<a href=\"https://datatable.readthedocs.io/en/latest/manual/comparison_with_pandas.html\" target=\"_blank\"> comparison between datatable and pandas</a></p>",
      "rawMarkdown": "Don't know why i didn't think about that, nice point @jpmiller \n\nAs suggested:\n-  Install datatable: ~9seconds\n- csvDT = dt.fread(mainFolder + 'train.csv'):  ~9 seconds\n- df = csvDT.to_pandas(): ~2 seconds \n\nGood advice, I will read data this way for my next notebook.\n\n@andy1010 you can check this page for a[ comparison between datatable and pandas](https://datatable.readthedocs.io/en/latest/manual/comparison_with_pandas.html)",
      "votes": null
    },
    {
      "id": "1573231",
      "postDate": "11/06/2021 12:14:11",
      "content": "<p>Didn't know about that <a href=\"https://www.kaggle.com/jpmiller\" target=\"_blank\">@jpmiller</a> I will keep it in mind thanks.</p>",
      "rawMarkdown": "Didn't know about that @jpmiller I will keep it in mind thanks.",
      "votes": null
    },
    {
      "id": "1574421",
      "postDate": "11/07/2021 14:27:40",
      "content": "<p>You're right. You could also divide the dataset by assets. And later on you may work with the assets relationships. </p>",
      "rawMarkdown": "You're right. You could also divide the dataset by assets. And later on you may work with the assets relationships.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1570401,
      "author_name": "carlmcbrideellis",
      "author_url": "",
      "post_date": "11/04/2021 05:43:30",
      "content": "<p>Dear <a href=\"https://www.kaggle.com/andy1010\" target=\"_blank\">@andy1010</a> </p>\n<p>May I heartily recommend  the <a href=\"https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets\" target=\"_blank\">\"Tutorial on reading large datasets\"</a> written by <a href=\"https://www.kaggle.com/rohanrao\" target=\"_blank\">Vopani</a>, introducing alternatives such as Dask, Datatable and the the Rapids <code>cudf</code>, which harnesses the power of the GPU's, and all affording considerable speedups w.r.t. pandas.  </p>\n<p>All the best,<br>\ncarl</p>",
      "votes": null,
      "replies": [
        {
          "id": 1570764,
          "author_name": "ajpass",
          "author_url": "",
          "post_date": "11/04/2021 11:02:55",
          "content": "<p>Already read that notebook, but still the best in this topic. Thanks <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1571046,
          "author_name": "andy1010",
          "author_url": "",
          "post_date": "11/04/2021 14:57:56",
          "content": "<p>Thanks for the nice notebook, very helpful resource!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1570595,
      "author_name": "faisalalsrheed",
      "author_url": "",
      "post_date": "11/04/2021 08:53:36",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/andy1010\" target=\"_blank\">@andy1010</a> </p>\n<p>This might help. <br>\n<a href=\"https://www.kaggle.com/pedrocouto39/fast-reading-w-pickle-feather-parquet-jay\" target=\"_blank\">https://www.kaggle.com/pedrocouto39/fast-reading-w-pickle-feather-parquet-jay</a><br>\n<a href=\"https://www.kaggle.com/c/jane-street-market-prediction/discussion/199233\" target=\"_blank\">https://www.kaggle.com/c/jane-street-market-prediction/discussion/199233</a><br>\n<a href=\"https://www.kaggle.com/pedrocouto39/jane-street-market-train-data-best-formats\" target=\"_blank\">https://www.kaggle.com/pedrocouto39/jane-street-market-train-data-best-formats</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 1570748,
          "author_name": "ajpass",
          "author_url": "",
          "post_date": "11/04/2021 10:49:34",
          "content": "<p>wow, jay seems super fast. Thanks for the links <a href=\"https://www.kaggle.com/faisalalsrheed\" target=\"_blank\">@faisalalsrheed</a> </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1570832,
      "author_name": "ajpass",
      "author_url": "",
      "post_date": "11/04/2021 12:09:26",
      "content": "<p>Alright, this question made me curious and I had to try. I made a notebook with the suggestions from: <a href=\"https://www.kaggle.com/faisalalsrheed\" target=\"_blank\">@faisalalsrheed</a> and <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> using the training data from the competition: <a href=\"https://www.kaggle.com/ajpass/reading-speed-comparation-between-file-formats\" target=\"_blank\">https://www.kaggle.com/ajpass/reading-speed-comparation-between-file-formats</a> . Hope it helps you :D</p>\n<p>Abstract: Jay format is the fastest but uses a library called datatable which doesn't have a very exhaustive set of data processing functions (as said in <a href=\"https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets)\" target=\"_blank\">https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets)</a>.</p>\n<p>P.S.: I also added all the advice given by <a href=\"https://www.kaggle.com/jpmiller\" target=\"_blank\">@jpmiller</a> which I think it's fantastic. </p>",
      "votes": null,
      "replies": [
        {
          "id": 1571052,
          "author_name": "andy1010",
          "author_url": "",
          "post_date": "11/04/2021 14:59:49",
          "content": "<p>Yes, I did get similar results using other data formats and Jay was the fastest. However, the process that's taking the longest for me is converting to pandas DataFrame since as mentioned, datatable does not have a very wide range of data processing functions. Thanks for the help anyways!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1572852,
          "author_name": "jpmiller",
          "author_url": "",
          "post_date": "11/06/2021 03:19:25",
          "content": "<p>You might try flipping the operations here.</p>\n<ul>\n<li>Use datatable to read in the csv and convert to pandas (much faster than a <code>pd.read_csv()</code>)</li>\n<li>Do your thing with the data in pandas</li>\n<li>Save the file back as <code>pd.to_parquet()</code> or feather, hd5</li>\n</ul>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1573200,
          "author_name": "ajpass",
          "author_url": "",
          "post_date": "11/06/2021 11:44:27",
          "content": "<p>Don't know why i didn't think about that, nice point <a href=\"https://www.kaggle.com/jpmiller\" target=\"_blank\">@jpmiller</a> </p>\n<p>As suggested:</p>\n<ul>\n<li>Install datatable: ~9seconds</li>\n<li>csvDT = dt.fread(mainFolder + 'train.csv'):  ~9 seconds</li>\n<li>df = csvDT.to_pandas(): ~2 seconds </li>\n</ul>\n<p>Good advice, I will read data this way for my next notebook.</p>\n<p><a href=\"https://www.kaggle.com/andy1010\" target=\"_blank\">@andy1010</a> you can check this page for a<a href=\"https://datatable.readthedocs.io/en/latest/manual/comparison_with_pandas.html\" target=\"_blank\"> comparison between datatable and pandas</a></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1570849,
      "author_name": "lucasmorin",
      "author_url": "",
      "post_date": "11/04/2021 12:30:34",
      "content": "<p>You might want to build a smaller data set for debugging purposes. </p>",
      "votes": null,
      "replies": [
        {
          "id": 1574421,
          "author_name": "ajpass",
          "author_url": "",
          "post_date": "11/07/2021 14:27:40",
          "content": "<p>You're right. You could also divide the dataset by assets. And later on you may work with the assets relationships. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1570995,
      "author_name": "danielbruintjies",
      "author_url": "",
      "post_date": "11/04/2021 14:34:45",
      "content": "<p>I'm not sure where you getting 19sec from, but your method is pretty fast for me, thanks!</p>\n<p>stats from kaggle cpu kernel:</p>\n<p>%%time<br>\ndata_folder = \"../input/g-research-crypto-forecasting/\"<br>\ndata_folder2 = \"../input/gresearch-crypto-forcasting-train/\"<br>\n​<br>\nasset_details = pd.read_csv(data_folder + 'asset_details.csv')<br>\ncrypto_df = dt.fread(data_folder2 + \"train.jay\").to_pandas()</p>\n<p>CPU times: user 908 ms, sys: 490 ms, total: 1.4 s<br>\nWall time: 987 ms</p>",
      "votes": null,
      "replies": [
        {
          "id": 1571044,
          "author_name": "andy1010",
          "author_url": "",
          "post_date": "11/04/2021 14:57:28",
          "content": "<p>Hmm, that's quite interesting. For me, reading in the data only takes about 25 milliseconds, however the conversion to pandas takes 15~ seconds. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1571787,
      "author_name": "pbokieee",
      "author_url": "",
      "post_date": "11/05/2021 06:48:55",
      "content": "<p>Using pickle is also a good way.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1572864,
          "author_name": "jpmiller",
          "author_url": "",
          "post_date": "11/06/2021 03:30:40",
          "content": "<p>Pickle is easy, versatile and fine for personal use. There may be issues though in more general applications.</p>\n<ul>\n<li><a href=\"https://www.benfrederickson.com/dont-pickle-your-data/\" target=\"_blank\">https://www.benfrederickson.com/dont-pickle-your-data/</a></li>\n<li><a href=\"https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html\" target=\"_blank\">https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html</a></li>\n</ul>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1572874,
          "author_name": "pbokieee",
          "author_url": "",
          "post_date": "11/06/2021 03:41:26",
          "content": "<p>Thanks for reminding ! 👍</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1573231,
          "author_name": "ajpass",
          "author_url": "",
          "post_date": "11/06/2021 12:14:11",
          "content": "<p>Didn't know about that <a href=\"https://www.kaggle.com/jpmiller\" target=\"_blank\">@jpmiller</a> I will keep it in mind thanks.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1572190,
      "author_name": "jaredsavage",
      "author_url": "",
      "post_date": "11/05/2021 13:46:24",
      "content": "<p>Just putting it out there… <br>\nvroom package in R: 12.562 seconds</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1573111,
      "author_name": "selectra",
      "author_url": "",
      "post_date": "11/06/2021 09:32:46",
      "content": "<p>Thank you so much for taking your time for making this post. Also, When pd.read_csv take 1 minute 19s for me, jay made it in 2 seconds. Insane difference.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1570343": "Since the data provided for the competition is relatively large, loading it as `pd.read_csv` takes extremely long (around 1 minute and 10 seconds). However, converting the data into `.jay` files speeds up the process by a lot (about 19 seconds).\n```\n# Converting to Jay Files\nimport pandas as pd\ntrain = pd.read_csv(\"../input/g-research-crypto-forecasting/train.csv\")\nimport datatable as dt\ndt.Frame(train).to_jay(\"g_research_crypto_forecasting.jay\")\n```\nOnce converted to Jay files, read in the data as follow\n```\nimport datatable as dt\ndata = dt.fread(\"../input/g-research-train-in-jay-format/g_research_crypto_forecasting.jay\").to_pandas()\n#Gives you a Pandas DataFrame\n```\nI hope this method can speed up your data reading process without having to wait for a whole minute just to read in the data.\nDoes anyone know other ways that can read the data faster? (19 seconds is still pretty slow 😂 I've tried Pickle and Feather)",
    "1570401": "Dear @andy1010 \n\n May I heartily recommend  the [\"Tutorial on reading large datasets\"](https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets) written by [Vopani](https://www.kaggle.com/rohanrao), introducing alternatives such as Dask, Datatable and the the Rapids `cudf`, which harnesses the power of the GPU's, and all affording considerable speedups w.r.t. pandas.  \n\nAll the best,\ncarl",
    "1570595": "Hi @andy1010 \n\nThis might help. \nhttps://www.kaggle.com/pedrocouto39/fast-reading-w-pickle-feather-parquet-jay\nhttps://www.kaggle.com/c/jane-street-market-prediction/discussion/199233\nhttps://www.kaggle.com/pedrocouto39/jane-street-market-train-data-best-formats",
    "1570748": "wow, jay seems super fast. Thanks for the links @faisalalsrheed",
    "1570764": "Already read that notebook, but still the best in this topic. Thanks @carlmcbrideellis",
    "1570832": "Alright, this question made me curious and I had to try. I made a notebook with the suggestions from: @faisalalsrheed and @carlmcbrideellis using the training data from the competition: https://www.kaggle.com/ajpass/reading-speed-comparation-between-file-formats . Hope it helps you :D\n\nAbstract: Jay format is the fastest but uses a library called datatable which doesn't have a very exhaustive set of data processing functions (as said in https://www.kaggle.com/rohanrao/tutorial-on-reading-large-datasets).\n\nP.S.: I also added all the advice given by @jpmiller which I think it's fantastic.",
    "1570849": "You might want to build a smaller data set for debugging purposes.",
    "1570995": "I'm not sure where you getting 19sec from, but your method is pretty fast for me, thanks!\n\nstats from kaggle cpu kernel:\n\n%%time\ndata_folder = \"../input/g-research-crypto-forecasting/\"\ndata_folder2 = \"../input/gresearch-crypto-forcasting-train/\"\n​\nasset_details = pd.read_csv(data_folder + 'asset_details.csv')\ncrypto_df = dt.fread(data_folder2 + \"train.jay\").to_pandas()\n\nCPU times: user 908 ms, sys: 490 ms, total: 1.4 s\nWall time: 987 ms",
    "1571044": "Hmm, that's quite interesting. For me, reading in the data only takes about 25 milliseconds, however the conversion to pandas takes 15~ seconds.",
    "1571046": "Thanks for the nice notebook, very helpful resource!",
    "1571052": "Yes, I did get similar results using other data formats and Jay was the fastest. However, the process that's taking the longest for me is converting to pandas DataFrame since as mentioned, datatable does not have a very wide range of data processing functions. Thanks for the help anyways!",
    "1571787": "Using pickle is also a good way.",
    "1572190": "Just putting it out there... \nvroom package in R: 12.562 seconds",
    "1572852": "You might try flipping the operations here.\n- Use datatable to read in the csv and convert to pandas (much faster than a `pd.read_csv()`)\n- Do your thing with the data in pandas\n- Save the file back as `pd.to_parquet()` or feather, hd5",
    "1572864": "Pickle is easy, versatile and fine for personal use. There may be issues though in more general applications.\n- https://www.benfrederickson.com/dont-pickle-your-data/\n- https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html",
    "1572874": "Thanks for reminding ! 👍",
    "1573111": "Thank you so much for taking your time for making this post. Also, When pd.read_csv take 1 minute 19s for me, jay made it in 2 seconds. Insane difference.",
    "1573200": "Don't know why i didn't think about that, nice point @jpmiller \n\nAs suggested:\n-  Install datatable: ~9seconds\n- csvDT = dt.fread(mainFolder + 'train.csv'):  ~9 seconds\n- df = csvDT.to_pandas(): ~2 seconds \n\nGood advice, I will read data this way for my next notebook.\n\n@andy1010 you can check this page for a[ comparison between datatable and pandas](https://datatable.readthedocs.io/en/latest/manual/comparison_with_pandas.html)",
    "1573231": "Didn't know about that @jpmiller I will keep it in mind thanks.",
    "1574421": "You're right. You could also divide the dataset by assets. And later on you may work with the assets relationships."
  },
  "source": "meta"
}