'Python Pandas: How to replace values more efficiently in terms of memory?
I have some large data frames that I need to replace its values. This operation, however, is killing me and is causing my machine to run out of memory:
# replace nan with missing string
df[col].replace(np.nan, '<missing>', inplace=True)
## Unable to allocate 2.11 GiB for an array with shape (45, 6286166) and data type object
Is there another way to go about replacing values that does not involve such a high cost?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|