Python Forum
pandas.read_sas with chunksize: IndexError list index out of range
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas.read_sas with chunksize: IndexError list index out of range
#1
Good morning,

I have read the rules about posting but i cannot attach a sample of my data or reproduce the entire error message as the data i am working on is located on a server without access to internet. I apologise for this inconvenience. I'll try to reproduce most of what is requested however below.

I am working with very big sas files (data on each job, hence millions of lines) and got memory error when i was trying to simple read them (they open fine in R or stata strangely). Therefore i searched and find the pandas.read_sas option to work with chunks of the data. My code is now the following:

df_chunk = pd.read_sas(r'file.sas7bdat', chunksize=500)

for chunk in df_chunk:  
    chunk_list.append(chunk)

At this point i get the following error (I am reproducing it here manually as i cannot copy paste):

Error:
line 660, in _chunk_to_dataframe if self.column_formats[j] in const.sas_date_formats: IndexError: list index out of range
Looking deeper in the error message, the issue seems to be in the underlying function "
_chunk_to_dataframe(self)
" in the following line :
if self.column_formats[j] in const.sas_date_formats 
Many thanks for your help,
Axelle
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Grouping in pandas/multi-index data frame Aleqsie 3 669 Jan-06-2024, 03:55 PM
Last Post: deanhystad
  Index out of range error standenman 0 1,093 May-22-2023, 10:35 PM
Last Post: standenman
  IndexError: invalid index to scalar variable. jyotib2610 3 3,087 Mar-10-2022, 09:55 AM
Last Post: jyotib2610
  IndexError: index 0 is out of bounds for axis 0 with size 0 atomxkai 2 5,464 Mar-03-2021, 08:26 AM
Last Post: atomxkai
  [split] Getting Index Error - list index out of range krishna 2 2,608 Jan-09-2021, 08:29 AM
Last Post: buran
  Comparing results within a list and appending to pandas dataframe Aryagm 1 2,348 Dec-17-2020, 01:08 PM
Last Post: palladium
  Cycle through Numpy range within another range(?) Zero01 0 2,015 Jul-31-2020, 02:37 PM
Last Post: Zero01
  [pandas] How to reshape the list Mekala 6 7,382 Jul-26-2020, 12:49 AM
Last Post: Mekala
  IndexError: index 0 is out of bounds for axis 0 with size 0 tmhsa 0 5,309 Apr-24-2020, 10:00 AM
Last Post: tmhsa
  Getting Index Error - list index out of range RahulSingh 2 6,147 Feb-03-2020, 07:17 AM
Last Post: RahulSingh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020