Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

csr_matric scipy lib

>>> row = np.array([0, 0, 1, 2, 2, 2])
>>> col = np.array([0, 2, 2, 0, 1, 2])
>>> data = np.array([1, 2, 3, 4, 5, 6])
>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()
array([[1, 0, 2],
       [0, 0, 3],
       [4, 5, 6]])
Comment

csr_matric scipy lib

>>> import numpy as np
>>> from scipy.sparse import csr_matrix
>>> csr_matrix((3, 4), dtype=np.int8).toarray()
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]], dtype=int8)
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib documentation download via 
Python :: rotating circular queue in python 
Python :: numpy delete 
Python :: clone keras model 
Python :: concatenate two tensors pytorch 
Python :: django queryset exists 
Python :: how to install docx in python 
Python :: list comprehension python if else 
Python :: even numbers from 1 to 100 in python 
Python :: python namespace 
Python :: how to get value from set in python 
Python :: python scope 
Python :: Write Python programs to print numbers from 1 to 10000 while loops 
Python :: python check if string in string 
Python :: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead 
Python :: tkinter icon 
Python :: plotly go axis labels 
Python :: spark df to pandas df 
Python :: install python3 in ubuntu 
Python :: read clipboard python 
Python :: python seaborn color map 
Python :: how to check if a number is even or odd in python 
Python :: convert a string into a list in Python 
Python :: python list object ids 
Python :: python mathematics 
Python :: kpss test python 
Python :: how to use the super 
Python :: pandas where retuning NaN 
Python :: python 3.7 install snakemake 
Python :: Merge two data frames based on common column values in Pandas 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =