0

Whenever I slice a data frame with loc iloc filter, etc. it increases my RAM usage, whats happening? why this does not just print the slice? If it is saving it in Out like it's suggested here, how can I avoid that behavior?

I'm using jupyter notebook in vscode, pandas==1.5.2.

juanmac
  • 121
  • 1
  • 12

1 Answers1

0

Here are a few steps you can take to decrease your ram usage while using jupyter-notebok:

  • Write functions for processing and only return the processed variable. This is the most important part, it will save a lot of hassle specially while using pandas
  • Clear garbage
import gc 
gc.collect()
  • Clear cache
import ctypes
libc = ctypes.CDLL("libc.so.6") # clearing cache 
libc.malloc_trim(0)
Musabbir Arrafi
  • 744
  • 4
  • 18