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 ;
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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.