Spyder, variable explorer, xpt











up vote
2
down vote

favorite












I'm coming to Python from a SAS background.



I've imported a SAS version 5 transport file (XPT) into python using:



df = pd.read_sas(r'C:mypathmyxpt.xpt')


The file is a simple SAS transport file, converted from a SAS dataset created with the following:



DATA myxpt;
DO i = 1 TO 10;
y = "XXX";
OUTPUT;
END;
RUN;


The file imports correctly and I can view the contents using:



print(df)


screenshot showing print of dataframe



However, when I view the file using the variable explorer, all character columns are shown as blank.



Screenshot showing data frame viewed through Variable explorer



I've tried reading this as a sas dataset instead of a transport file and importing this into Python but have the same problem.



I've also tried creating a dataframe within python containing character columns and this displays correctly within the variable explorer.



Any suggestions what's going wrong?



Thanks in advance.










share|improve this question






















  • Column Y is a column of binary strings. I believe you have to decode it first. The variable explorer cannot guess the correct encoding and apprently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info in the variable explorer makes any sense. This stackoverflow.com/questions/17615414/… might help.
    – Francio Rodrigues
    Nov 19 at 14:12








  • 1




    That works perfectly thanks for the quick response. Building on your answer I see that I can specify the encoding ='utf8' on the import of the file which also resolves the issue.
    – Easynow
    Nov 19 at 14:25










  • Great! I will write a complete answer with what you have done too.
    – Francio Rodrigues
    Nov 19 at 15:14















up vote
2
down vote

favorite












I'm coming to Python from a SAS background.



I've imported a SAS version 5 transport file (XPT) into python using:



df = pd.read_sas(r'C:mypathmyxpt.xpt')


The file is a simple SAS transport file, converted from a SAS dataset created with the following:



DATA myxpt;
DO i = 1 TO 10;
y = "XXX";
OUTPUT;
END;
RUN;


The file imports correctly and I can view the contents using:



print(df)


screenshot showing print of dataframe



However, when I view the file using the variable explorer, all character columns are shown as blank.



Screenshot showing data frame viewed through Variable explorer



I've tried reading this as a sas dataset instead of a transport file and importing this into Python but have the same problem.



I've also tried creating a dataframe within python containing character columns and this displays correctly within the variable explorer.



Any suggestions what's going wrong?



Thanks in advance.










share|improve this question






















  • Column Y is a column of binary strings. I believe you have to decode it first. The variable explorer cannot guess the correct encoding and apprently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info in the variable explorer makes any sense. This stackoverflow.com/questions/17615414/… might help.
    – Francio Rodrigues
    Nov 19 at 14:12








  • 1




    That works perfectly thanks for the quick response. Building on your answer I see that I can specify the encoding ='utf8' on the import of the file which also resolves the issue.
    – Easynow
    Nov 19 at 14:25










  • Great! I will write a complete answer with what you have done too.
    – Francio Rodrigues
    Nov 19 at 15:14













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm coming to Python from a SAS background.



I've imported a SAS version 5 transport file (XPT) into python using:



df = pd.read_sas(r'C:mypathmyxpt.xpt')


The file is a simple SAS transport file, converted from a SAS dataset created with the following:



DATA myxpt;
DO i = 1 TO 10;
y = "XXX";
OUTPUT;
END;
RUN;


The file imports correctly and I can view the contents using:



print(df)


screenshot showing print of dataframe



However, when I view the file using the variable explorer, all character columns are shown as blank.



Screenshot showing data frame viewed through Variable explorer



I've tried reading this as a sas dataset instead of a transport file and importing this into Python but have the same problem.



I've also tried creating a dataframe within python containing character columns and this displays correctly within the variable explorer.



Any suggestions what's going wrong?



Thanks in advance.










share|improve this question













I'm coming to Python from a SAS background.



I've imported a SAS version 5 transport file (XPT) into python using:



df = pd.read_sas(r'C:mypathmyxpt.xpt')


The file is a simple SAS transport file, converted from a SAS dataset created with the following:



DATA myxpt;
DO i = 1 TO 10;
y = "XXX";
OUTPUT;
END;
RUN;


The file imports correctly and I can view the contents using:



print(df)


screenshot showing print of dataframe



However, when I view the file using the variable explorer, all character columns are shown as blank.



Screenshot showing data frame viewed through Variable explorer



I've tried reading this as a sas dataset instead of a transport file and importing this into Python but have the same problem.



I've also tried creating a dataframe within python containing character columns and this displays correctly within the variable explorer.



Any suggestions what's going wrong?



Thanks in advance.







python pandas sas spyder






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 14:06









Easynow

205




205












  • Column Y is a column of binary strings. I believe you have to decode it first. The variable explorer cannot guess the correct encoding and apprently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info in the variable explorer makes any sense. This stackoverflow.com/questions/17615414/… might help.
    – Francio Rodrigues
    Nov 19 at 14:12








  • 1




    That works perfectly thanks for the quick response. Building on your answer I see that I can specify the encoding ='utf8' on the import of the file which also resolves the issue.
    – Easynow
    Nov 19 at 14:25










  • Great! I will write a complete answer with what you have done too.
    – Francio Rodrigues
    Nov 19 at 15:14


















  • Column Y is a column of binary strings. I believe you have to decode it first. The variable explorer cannot guess the correct encoding and apprently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info in the variable explorer makes any sense. This stackoverflow.com/questions/17615414/… might help.
    – Francio Rodrigues
    Nov 19 at 14:12








  • 1




    That works perfectly thanks for the quick response. Building on your answer I see that I can specify the encoding ='utf8' on the import of the file which also resolves the issue.
    – Easynow
    Nov 19 at 14:25










  • Great! I will write a complete answer with what you have done too.
    – Francio Rodrigues
    Nov 19 at 15:14
















Column Y is a column of binary strings. I believe you have to decode it first. The variable explorer cannot guess the correct encoding and apprently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info in the variable explorer makes any sense. This stackoverflow.com/questions/17615414/… might help.
– Francio Rodrigues
Nov 19 at 14:12






Column Y is a column of binary strings. I believe you have to decode it first. The variable explorer cannot guess the correct encoding and apprently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info in the variable explorer makes any sense. This stackoverflow.com/questions/17615414/… might help.
– Francio Rodrigues
Nov 19 at 14:12






1




1




That works perfectly thanks for the quick response. Building on your answer I see that I can specify the encoding ='utf8' on the import of the file which also resolves the issue.
– Easynow
Nov 19 at 14:25




That works perfectly thanks for the quick response. Building on your answer I see that I can specify the encoding ='utf8' on the import of the file which also resolves the issue.
– Easynow
Nov 19 at 14:25












Great! I will write a complete answer with what you have done too.
– Francio Rodrigues
Nov 19 at 15:14




Great! I will write a complete answer with what you have done too.
– Francio Rodrigues
Nov 19 at 15:14












1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










Column Y is a column of binary strings. You have to decode it first. The variable explorer cannot guess the correct encoding and apparently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info makes any sense.



As you have noted, it is possible to specify the encoding in the import function:



df = pd.read_sas(r'C:mypathmyxpt.xpt', encoding='utf8')



As a sidenote, you should always be aware and preferably explicit of the encodings in use to avoid major headaches.



For a list of all available encodings and ther aliases check here.






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',
    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%2f53376390%2fspyder-variable-explorer-xpt%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








    up vote
    4
    down vote



    accepted










    Column Y is a column of binary strings. You have to decode it first. The variable explorer cannot guess the correct encoding and apparently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info makes any sense.



    As you have noted, it is possible to specify the encoding in the import function:



    df = pd.read_sas(r'C:mypathmyxpt.xpt', encoding='utf8')



    As a sidenote, you should always be aware and preferably explicit of the encodings in use to avoid major headaches.



    For a list of all available encodings and ther aliases check here.






    share|improve this answer

























      up vote
      4
      down vote



      accepted










      Column Y is a column of binary strings. You have to decode it first. The variable explorer cannot guess the correct encoding and apparently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info makes any sense.



      As you have noted, it is possible to specify the encoding in the import function:



      df = pd.read_sas(r'C:mypathmyxpt.xpt', encoding='utf8')



      As a sidenote, you should always be aware and preferably explicit of the encodings in use to avoid major headaches.



      For a list of all available encodings and ther aliases check here.






      share|improve this answer























        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        Column Y is a column of binary strings. You have to decode it first. The variable explorer cannot guess the correct encoding and apparently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info makes any sense.



        As you have noted, it is possible to specify the encoding in the import function:



        df = pd.read_sas(r'C:mypathmyxpt.xpt', encoding='utf8')



        As a sidenote, you should always be aware and preferably explicit of the encodings in use to avoid major headaches.



        For a list of all available encodings and ther aliases check here.






        share|improve this answer












        Column Y is a column of binary strings. You have to decode it first. The variable explorer cannot guess the correct encoding and apparently does not show binary strings. If you do not know the encoding you will have to guess. Try df['utf8']=df.Y.str.decode('utf8') and see if the info makes any sense.



        As you have noted, it is possible to specify the encoding in the import function:



        df = pd.read_sas(r'C:mypathmyxpt.xpt', encoding='utf8')



        As a sidenote, you should always be aware and preferably explicit of the encodings in use to avoid major headaches.



        For a list of all available encodings and ther aliases check here.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 at 15:23









        Francio Rodrigues

        6461817




        6461817






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53376390%2fspyder-variable-explorer-xpt%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

            Costa Masnaga

            Fotorealismo

            Sidney Franklin