By default, return float64, but provide options for reading different formats.
See original GitHub issueI think it’s a good idea to return np.float32
by default (although I’m not 100% sure because the default type in NumPy is np.float64
).
If the file has 64bit values, however, they shouldn’t be truncated by default.
So probably the default argument to read()
should be format=None
which should be changed appropriately within the function.
BTW, format
may not be the best name choice for this parameter, maybe dtype
would be rather what people would expect?
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
By default, return float64, but provide options for reading ...
I think it's a good idea to return np.float32 by default (although I'm not 100% sure because the default type in NumPy is...
Read more >Data Types and Formats – Data Analysis and Visualization in ...
Pandas and base Python use slightly different names for data types. ... pandas will default to float64, in case your missing value has...
Read more >float64 with pandas to_csv - python - Stack Overflow
UPDATE: Answer was accurate at time of writing, and floating point precision is still not something you get by default with to_csv/read_csv ...
Read more >IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
Lines with too many fields (e.g. a csv line with too many commas) will by default cause an exception to be raised, and...
Read more >Overview of Pandas Data Types - Practical Business Python
This article will discuss the basic pandas data types (aka dtypes ), how they map to python and numpy data types and the...
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
subtype
is a property ofsoundfile.SoundFile
and can have any value ofsoundfile._subtypes
.Interesting point. Come to think of it, I don’t see many reasons why we shouldn’t just switch everything over to
np.float64
by default. In Numpy, pretty much everything isnp.float64
by default.The only argument against that would be that there is no microphone able to record more than 24 bits, let alone ears cabable of hearing more, which makes anything more than 32 bits kind of a waste. I can see 64 bit being useful for non-audio data though.
One could also make an argument that if the source data is, say,
np.int16
,read()
should return exactly that. I don’t think there is much merit to this, though, since numpy integers violate too many pythonic assumptions about numbers (no infinite precision and overflow). How about providing something likeread_native()
, which would return the native data format of the file?