Comments (2)
So the above solution is not quite feasible as we're dealing with rows in the code instead of columns. An easy fix seems to be to take the transpose but that takes too long (13.5 s +/- ~100 ms) on my machine. So ended up with the following solution which is definitely more memory intensive (the product of self.A.sparse.to_dense() takes almost 2000MB instead of ~124MB).
dtypes = self.A.dtypes
self.A = self.A.sparse.to_dense()
self.A.loc[bo_cutoff,:] = self.A.loc[bo_cutoff,:].abs()
self.A = self.A.astype(dtypes)
from ecospold2matrix.
Hello,
I have the same problem with the "TypeError: SparseArray does not support item assignment via setitem".
I have tried to add as you suggest this 4 lines (dtypes = self.A.dtypes
self.A = self.A.sparse.to_dense()
self.A.loc[bo_cutoff,:] = self.A.loc[bo_cutoff,:].abs()
self.A = self.A.astype(dtypes)) but now I have a new error :
ValueError Traceback (most recent call last)
in
----> 1 parser.ecospold_to_Leontief(with_absolute_flows=True)
~/opt/anaconda3/lib/python3.7/site-packages/ecospold2matrix/ecospold2matrix.py in ecospold_to_Leontief(self, fileformats, with_absolute_flows, lci_check, rtol, atol, imax, characterisation_file, ardaidmatching_file)
432
433 # Save system to file
--> 434 self.save_system(fileformats)
435
436 # Read/load lci cummulative emissions and perform quality check
~/opt/anaconda3/lib/python3.7/site-packages/ecospold2matrix/ecospold2matrix.py in save_system(self, file_formats)
2202 STR_header = STR_header.reshape((1, -1))
2203
-> 2204 C = scipy.sparse.csr_matrix(self.C.sparse.to_coo())
2205 IMP_header = self.IMP.columns.values
2206 IMP_header = IMP_header.reshape((1, -1))
~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/sparse.py in to_coo(self)
2225 from scipy.sparse import coo_matrix
2226
-> 2227 dtype = find_common_type(self._parent.dtypes)
2228 if isinstance(dtype, SparseDtype):
2229 dtype = dtype.subtype
~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/dtypes/cast.py in find_common_type(types)
1136
1137 if len(types) == 0:
-> 1138 raise ValueError("no types given")
1139
1140 first = types[0]
ValueError: no types given
Did you manage to solve your error or did you have other errors as I have ?
from ecospold2matrix.
Related Issues (10)
- closing parenthesis bug HOT 1
- Leontief coefficients format
- `ecospold_to_Leontief` throws error `OperationalError: duplicate column name: id`
- How can I obtain the Z matrix? HOT 1
- What's the difference between "F matrix" and "E matrix"?
- xml files contain BOM HOT 1
- String error in read_characterisation HOT 3
- fillna behavior HOT 4
- Error when run both master and dev branch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecospold2matrix.