как переписать код так, чтобы это работало и уместилось в текущую память ПК?…
- User
как переписать код так, чтобы это работало и уместилось в текущую память ПК? --------------------------------------------------------------------------- MemoryError Traceback (most recent call last) Cell In[4], line 1 ----> 1 df = df.append(df_2)
File c:\Work\Anaconda3\envs\py_dvc\lib\site-packages\pandas\core\frame.py:8965, in DataFrame.append(self, other, ignore_index, verify_integrity, sort) 8962 else: 8963 to_concat = [self, other] 8964 return ( -> 8965 concat( 8966 to_concat, 8967 ignore_index=ignore_index, 8968 verify_integrity=verify_integrity, 8969 sort=sort, 8970 ) 8971 ).finalize(self, method="append")
File c:\Work\Anaconda3\envs\py_dvc\lib\site-packages\pandas\util_decorators.py:311, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, **kwargs) 305 if len(args) > num_allow_args: 306 warnings.warn( 307 msg.format(arguments=arguments), 308 FutureWarning, 309 stacklevel=stacklevel, 310 ) --> 311 return func(*args, **kwargs) ... 148 # coerce to object 149 to_concat = [x.astype("object") for x in to_concat] --> 151 return np.concatenate(to_concat, axis=axis)
MemoryError: Unable to allocate 15.6 GiB for an array with shape (1397, 1500000) and data type float64
- Assistant
The
MemoryErroryou're encountering indicates that your current operation—which is appending to —is exceeding the available memory on your PC. When you append one DataFrame to another using , it creates a copy of the data in memory, which can use up twice the amount of memory than you would expect. This is often an issue with large datasets.