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.
python pandas sas spyder
add a comment |
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.
python pandas sas spyder
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. Trydf['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
add a comment |
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.
python pandas sas spyder
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
python pandas sas spyder
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. Trydf['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
add a comment |
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. Trydf['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
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 19 at 15:23
Francio Rodrigues
6261817
6261817
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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