df.values
is a numpy array, and accessing values that way is always faster than np.array
.
scipy.sparse.csr_matrix(df.values)
You might need to take the transpose first, like df.values.T
. In DataFrames, the columns are axis 0.
More Related Contents:
- Most efficient way to sort an array into bins specified by an index array?
- Populate a Pandas SparseDataFrame from a SciPy Sparse Matrix
- Parse a Pandas column to Datetime when importing table from SQL database and filtering rows by date
- Convert pandas dataframe to NumPy array
- What is the difference between NaN and None?
- How to do exponential and logarithmic curve fitting in Python? I found only polynomial fitting
- Strings in a DataFrame, but dtype is object
- How to smooth a curve in the right way?
- What does axis in pandas mean?
- FutureWarning: elementwise comparison failed; returning scalar, but in the future will perform elementwise comparison
- How to solve a pair of nonlinear equations using Python?
- How to map numeric data into categories / bins in Pandas dataframe
- Coalesce values from 2 columns into a single column in a pandas dataframe
- Pandas: Subtracting two date columns and the result being an integer
- Convert timedelta64[ns] column to seconds in Python Pandas DataFrame
- numpy.where() detailed, step-by-step explanation / examples [closed]
- How to plot empirical cdf (ecdf)
- Pandas pd.Series.isin performance with set versus array
- Get week start date (Monday) from a date column in Python (pandas)?
- Get coordinates of local maxima in 2D array above certain value
- pandas distinction between str and object types
- How to share numpy random state of a parent process with child processes?
- Generating Discrete random variables with specified weights using SciPy or NumPy
- How to get the indices list of all NaN value in numpy array?
- setting spacing between grouped bar plots in matplotlib
- Compute a confidence interval from sample data assuming unknown distribution
- Interpolating a closed curve using scipy
- Procrustes Analysis with NumPy?
- What is the Big O Complexity of Reversing the Order of Columns in Pandas DataFrame?
- How to include constraint to Scipy NNLS function solution so that it sums to 1