AWS SageMaker pd.read_pickle() doesn't work but read_csv() does?










1















I've recently been trying to train some models on an AWS SageMaker jupyter notebook instance.



Everything is worked very well until I tried to load in some custom dataset (REDD) through files.



I have the dataframes stored in Pickle (.pkl) files on an S3 bucket. I couldn't manage to read them into sagemaker so I decided to convert them to csv's as this seemed to work but I ran into a problem. This data has an index of type datetime64 and when using .to_csv() this index gets converted to pure text and it loses it's data structure (and I need to keep this specific index for correct plotting.)



So I decided to try the Pickle files again but I can't get it to work and have no idea why.



The following code for csv's works but I can't use it due to the index problem:



bucket = 'sagemaker-peno'
houses_dfs =
data_key = 'compressed_data/'
data_location = 's3:///'.format(bucket, data_key)
for file in range(6):
houses_dfs[file+1] = pd.read_csv(data_location+'house_'+str(file+1)+'.csv', index_col='Unnamed: 0')


But this code does NOT work even though it uses almost the exact same syntax:



bucket = 'sagemaker-peno'
houses_dfs =
data_key = 'compressed_data/'
data_location = 's3:///'.format(bucket, data_key)
for file in range(6):
houses_dfs[file+1] = pd.read_pickle(data_location+'house_'+str(file+1)+'.pkl')


Yes it's 100% the correct path, because the csv and pkl files are stored in the same directory (compressed_data).



It throws me this error while using the Pickle method:



FileNotFoundError: [Errno 2] No such file or directory: 's3://sagemaker-peno/compressed_data/house_1.pkl'


I hope to find someone who has dealt with this before and can solve the read_pickle() issue or as an alternative fix my datetime64 type issue with csv's.



Thanks in advance!










share|improve this question


























    1















    I've recently been trying to train some models on an AWS SageMaker jupyter notebook instance.



    Everything is worked very well until I tried to load in some custom dataset (REDD) through files.



    I have the dataframes stored in Pickle (.pkl) files on an S3 bucket. I couldn't manage to read them into sagemaker so I decided to convert them to csv's as this seemed to work but I ran into a problem. This data has an index of type datetime64 and when using .to_csv() this index gets converted to pure text and it loses it's data structure (and I need to keep this specific index for correct plotting.)



    So I decided to try the Pickle files again but I can't get it to work and have no idea why.



    The following code for csv's works but I can't use it due to the index problem:



    bucket = 'sagemaker-peno'
    houses_dfs =
    data_key = 'compressed_data/'
    data_location = 's3:///'.format(bucket, data_key)
    for file in range(6):
    houses_dfs[file+1] = pd.read_csv(data_location+'house_'+str(file+1)+'.csv', index_col='Unnamed: 0')


    But this code does NOT work even though it uses almost the exact same syntax:



    bucket = 'sagemaker-peno'
    houses_dfs =
    data_key = 'compressed_data/'
    data_location = 's3:///'.format(bucket, data_key)
    for file in range(6):
    houses_dfs[file+1] = pd.read_pickle(data_location+'house_'+str(file+1)+'.pkl')


    Yes it's 100% the correct path, because the csv and pkl files are stored in the same directory (compressed_data).



    It throws me this error while using the Pickle method:



    FileNotFoundError: [Errno 2] No such file or directory: 's3://sagemaker-peno/compressed_data/house_1.pkl'


    I hope to find someone who has dealt with this before and can solve the read_pickle() issue or as an alternative fix my datetime64 type issue with csv's.



    Thanks in advance!










    share|improve this question
























      1












      1








      1








      I've recently been trying to train some models on an AWS SageMaker jupyter notebook instance.



      Everything is worked very well until I tried to load in some custom dataset (REDD) through files.



      I have the dataframes stored in Pickle (.pkl) files on an S3 bucket. I couldn't manage to read them into sagemaker so I decided to convert them to csv's as this seemed to work but I ran into a problem. This data has an index of type datetime64 and when using .to_csv() this index gets converted to pure text and it loses it's data structure (and I need to keep this specific index for correct plotting.)



      So I decided to try the Pickle files again but I can't get it to work and have no idea why.



      The following code for csv's works but I can't use it due to the index problem:



      bucket = 'sagemaker-peno'
      houses_dfs =
      data_key = 'compressed_data/'
      data_location = 's3:///'.format(bucket, data_key)
      for file in range(6):
      houses_dfs[file+1] = pd.read_csv(data_location+'house_'+str(file+1)+'.csv', index_col='Unnamed: 0')


      But this code does NOT work even though it uses almost the exact same syntax:



      bucket = 'sagemaker-peno'
      houses_dfs =
      data_key = 'compressed_data/'
      data_location = 's3:///'.format(bucket, data_key)
      for file in range(6):
      houses_dfs[file+1] = pd.read_pickle(data_location+'house_'+str(file+1)+'.pkl')


      Yes it's 100% the correct path, because the csv and pkl files are stored in the same directory (compressed_data).



      It throws me this error while using the Pickle method:



      FileNotFoundError: [Errno 2] No such file or directory: 's3://sagemaker-peno/compressed_data/house_1.pkl'


      I hope to find someone who has dealt with this before and can solve the read_pickle() issue or as an alternative fix my datetime64 type issue with csv's.



      Thanks in advance!










      share|improve this question














      I've recently been trying to train some models on an AWS SageMaker jupyter notebook instance.



      Everything is worked very well until I tried to load in some custom dataset (REDD) through files.



      I have the dataframes stored in Pickle (.pkl) files on an S3 bucket. I couldn't manage to read them into sagemaker so I decided to convert them to csv's as this seemed to work but I ran into a problem. This data has an index of type datetime64 and when using .to_csv() this index gets converted to pure text and it loses it's data structure (and I need to keep this specific index for correct plotting.)



      So I decided to try the Pickle files again but I can't get it to work and have no idea why.



      The following code for csv's works but I can't use it due to the index problem:



      bucket = 'sagemaker-peno'
      houses_dfs =
      data_key = 'compressed_data/'
      data_location = 's3:///'.format(bucket, data_key)
      for file in range(6):
      houses_dfs[file+1] = pd.read_csv(data_location+'house_'+str(file+1)+'.csv', index_col='Unnamed: 0')


      But this code does NOT work even though it uses almost the exact same syntax:



      bucket = 'sagemaker-peno'
      houses_dfs =
      data_key = 'compressed_data/'
      data_location = 's3:///'.format(bucket, data_key)
      for file in range(6):
      houses_dfs[file+1] = pd.read_pickle(data_location+'house_'+str(file+1)+'.pkl')


      Yes it's 100% the correct path, because the csv and pkl files are stored in the same directory (compressed_data).



      It throws me this error while using the Pickle method:



      FileNotFoundError: [Errno 2] No such file or directory: 's3://sagemaker-peno/compressed_data/house_1.pkl'


      I hope to find someone who has dealt with this before and can solve the read_pickle() issue or as an alternative fix my datetime64 type issue with csv's.



      Thanks in advance!







      pandas csv amazon-s3 pickle aws-sagemaker






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 12:20









      Dirkx SenneDirkx Senne

      5810




      5810






















          1 Answer
          1






          active

          oldest

          votes


















          0














          read_pickle() likes the full path more than a relative path from where it was run. This fixed my issue.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280902%2faws-sagemaker-pd-read-pickle-doesnt-work-but-read-csv-does%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            read_pickle() likes the full path more than a relative path from where it was run. This fixed my issue.






            share|improve this answer



























              0














              read_pickle() likes the full path more than a relative path from where it was run. This fixed my issue.






              share|improve this answer

























                0












                0








                0







                read_pickle() likes the full path more than a relative path from where it was run. This fixed my issue.






                share|improve this answer













                read_pickle() likes the full path more than a relative path from where it was run. This fixed my issue.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 20:32









                Dirkx SenneDirkx Senne

                5810




                5810





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280902%2faws-sagemaker-pd-read-pickle-doesnt-work-but-read-csv-does%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo