BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
acordes
Rhodochrosite | Level 12

Why Do I get the error message 

"Pandas is not installed, so you can't use this function"

 

when running this code?

I do see the correct print (df_exe) output in the log.

 

proc python ;
   submit ;

import pandas as pd
import numpy as np

# Creating a DataFrame by passing a dictionary of objects
df_exe = pd.DataFrame({
"A": 1.0,
"B": pd.Timestamp("20130102"),
"C": pd.Series(1, index=list(range(4)), dtype="float32"),
"D": np.array([3] * 4, dtype="int32"),
"E": pd.Categorical(["test", "train", "test", "train"]),
"F": "foo"
})

print (df_exe)

# Send the data to SAS using PROC PYTHON callback method
ds = SAS.df2sd(df_exe,"userdata")

   endsubmit ;
run ;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Stu_SAS
SAS Employee

Hey @acordes! I tested your code on my Viya environment and it worked as expected:

>>>
     A          B    C  D      E    F
0  1.0 2013-01-02  1.0  3   test  foo
1  1.0 2013-01-02  1.0  3  train  foo
2  1.0 2013-01-02  1.0  3   test  foo
3  1.0 2013-01-02  1.0  3  train  foo
Note that Indexes are not transferred over as columns. Only actual columns are transferred
>>> 
NOTE: PROCEDURE PYTHON used (Total process time):
      real time           12.25 seconds
      cpu time            0.03 seconds

This must mean that pandas is not installed in your Viya Python environment. To add packages to your Python environment in SAS, check out this blog on using the SAS Configurator for Open Source to Build Python and R.

View solution in original post

1 REPLY 1
Stu_SAS
SAS Employee

Hey @acordes! I tested your code on my Viya environment and it worked as expected:

>>>
     A          B    C  D      E    F
0  1.0 2013-01-02  1.0  3   test  foo
1  1.0 2013-01-02  1.0  3  train  foo
2  1.0 2013-01-02  1.0  3   test  foo
3  1.0 2013-01-02  1.0  3  train  foo
Note that Indexes are not transferred over as columns. Only actual columns are transferred
>>> 
NOTE: PROCEDURE PYTHON used (Total process time):
      real time           12.25 seconds
      cpu time            0.03 seconds

This must mean that pandas is not installed in your Viya Python environment. To add packages to your Python environment in SAS, check out this blog on using the SAS Configurator for Open Source to Build Python and R.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 918 views
  • 0 likes
  • 2 in conversation