Skip to content

Commit b52f204

Browse files
committed
Clarified error in read_sas method when buffer object provided without format
1 parent f79bc7a commit b52f204

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ Performance Improvements
271271
- Improved performance of ``pd.wide_to_long()`` (:issue:`14779`)
272272
- Increased performance of ``pd.factorize()`` by releasing the GIL with ``object`` dtype when inferred as strings (:issue:`14859`)
273273

274+
- When reading buffer object in ``read_sas()`` method without specified format, filepath string is inferred rather than buffer object. Error is now thrown if buffer object is provided without format {sas7bdat|xport} specification.
274275

275276

276277
.. _whatsnew_0200.bug_fixes:

pandas/io/sas/sasreader.py

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def read_sas(filepath_or_buffer, format=None, index=None, encoding=None,
3131
"""
3232

3333
if format is None:
34+
bufferr = "Format unrecognized. If buffer object, specify format")
35+
if type(filesize_or_buffer) != str:
36+
raise TypeError(bufferr)
3437
try:
3538
fname = filepath_or_buffer.lower()
3639
if fname.endswith(".xpt"):

0 commit comments

Comments
 (0)