MCA : 'SparseDataFrame' object has no attribute 'to_numpy'
See original GitHub issueI’m trying to execute the following code -
import prince
mca = prince.MCA(n_components=10,n_iter=5,copy=True,check_input=True,engine='auto',random_state=10)
mca_model=mca.fit(df_sample)
The problem is that OneHotEncoder has sparse set to True, so it returns a sparse dataframe. But the fit function has the following piece of code -
if isinstance(X, pd.DataFrame):
X = X.to_numpy()
But to_numpy cannot be applied to sparse dataframes. As a result I’m getting the following error-
AttributeError: ‘SparseDataFrame’ object has no attribute ‘to_numpy’
Not sure if this is a bug or if i’m doing something wrong.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How to fix AttributeError: 'Series' object has no attribute ...
Check the version of your pandas library: import pandas print(pandas.__version__). If your version is less than 0.24.1:
Read more >dataframe' object has no attribute 'to_numpy' ( Solved )
Suppose you want to convert the dataframe to numpy and you are getting dataframe' object has no attribute 'to_numpy' error then how you...
Read more >Sparse data structures — pandas 1.5.2 documentation
The SparseDataFrame.default_kind and SparseDataFrame.default_fill_value attributes have no replacement. Interaction with scipy.sparse ...
Read more >[QST] Error ('numpy.ndarray' object has no attribute ... - GitHub
I am trying to run MNMG KMeans algorithm on a single GPU node using this notebook. I am using vanilla code. I get...
Read more >Python - 'DataFrame' object has no attribute 'as_matrix
DataFrames consist of rows, columns, and data. The as_matrix() method was used to return a NumPy array, this NumPy array is created when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep, got it.
I’m on holiday at the moment, but I’ll work on it when I get back in ~10 days.
No, sorry. You are right - I got it working now with an older version of pandas. Thank you!