`.write` does not save `None` values
See original GitHub issueDescription
When saving an AnnData object to disk, keys of a dictionary whose value is None
seem not to be saved.
import numpy as np
import scanpy as sc
from anndata import AnnData
adata = AnnData(X=np.eye(3), uns={'key_1': 0, 'key_2': None})
adata.write('adata.h5ad')
_adata = sc.read('adata.h5ad')
gives
>>> _adata
AnnData object with n_obs × n_vars = 3 × 3
uns: 'key_1'
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
`.write` does not save `None` values · Issue #673 - GitHub
Description When saving an AnnData object to disk, keys of a dictionary whose value is None seem not to be saved. import numpy...
Read more >Writing "None" to a file in python - Stack Overflow
I'm parsing this file in Python, and I'm writing a file that every row in it will be a record (Comma separated) I've...
Read more >Dealing with Missing Values NaN and None in Python - Medium
First of all, let's look at the data type of Python NaN and None . numpy.nan is IEEE 754 floating point representation of...
Read more >Python | Remove None values from list - GeeksforGeeks
There can be multiple methods to remove None values from a Python list. ... We just check for not None values and construct...
Read more >Write a data frame to a delimited file — write_delim • readr
needed - Values are only quoted if needed: if they contain a delimiter, quote, or newline. all - Quote all fields. none -...
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
Just for the sake of documenting this somewhere: I ran into this issue when I used the
log1p
function, which as a default writes{"base": None}
touns
. However after saving and reloading the object, an error was thrown withrank_genes_groups
(code), because it is looking for thebase
key which is not present anymore.BTW, this is also an issue if you have
None
in one of your columns:Traceback
Though it does work for