I am currently getting this error when running my code: TypeError: SparseDataFrame() takes no arguments. How do I fix this?

Viewed 2339

I am currently getting this error when running my code: TypeError: SparseDataFrame() takes no arguments. How do I fix this?

View the code below.

churndrop = churn.drop(['Churn'],axis=1) #drops churn column

x= churndrop #creates dataframe 

y= churntarget # creates dataframe
y = np.ravel(y) # unravels y
y # shows y

from sklearn.model_selection import train_test_split #imports sklearn
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=0) # creates 
#test and train data
from sklearn.preprocessing import StandardScaler #import scaller

sc = StandardScaler() # sets sc to standard scaler
X_train = sc.fit_transform(X_train) #transforms data
X_test = sc.transform(X_test) # transforms data

x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.2) # test train
#x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.4)# extra line 
import light_famd # imports famd
from light_famd import FAMD #famd

famd= FAMD(n_components=2) # creates famd variable with two components


famd.fit_transform(x_test) # fits test

print(famd.explained_variance_) # prints variance

print(famd.explained_variance_rati`enter code here`o_) # prints explained variance
1 Answers

In the new version of Pandas, SparseDataFrame() is no longer available which is documented here.

Note

SparseSeries and SparseDataFrame were removed in pandas 1.0.0. This migration guide is present to aid in migrating from previous versions

So, for example, from the Docs,

#Previous Method
pd.SparseDataFrame({"A": [0, 1]})

#New Method
pd.DataFrame({"A": pd.arrays.SparseArray([0, 1])})

For More, Visit the Docs

Related