Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applying formats using fetch or to_frame makes all DataFrame columns objects #147

Open
pestyld opened this issue Dec 22, 2022 · 0 comments

Comments

@pestyld
Copy link

pestyld commented Dec 22, 2022

If you have formats on only a few columns in a CAS table and try to apply the formats to the SASDataFrame, the swat package converts all columns to objects, even if the column is a simple number.

For example:

Packages

import swat
import pandas as pd

Connect to CAS

conn = ##connection info

load data to CAS

data = r'https://support.sas.com/documentation/onlinedoc/viya/exampledatasets/cars.csv'
tbl = conn.upload_file(data,
casout = {'name':'cars_upload', 'caslib':'casuser','replace':True},
importoptions={
'stripBlanks':True,
'guessRows':200,
'vars':{
'MSRP':{'format':'dollar16.'},
'Weight':{'format':'comma16.'}
}})

Only the MSRP and Weight columns have a format

tbl.columnInfo()

image

Pull the CAS table to the client as a SASDataFrame and apply the formats. This works as expected

df = tbl.to_frame(format=True)
df.head()

image

View the data types of the SASDataFrame

image

Everything turns into an object. It seems like only the formatted columns should be converted. Numeric columns without formats should remain numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant