作者:JayantKwon | 来源:互联网 | 2023-09-11 08:53
IhaveRAMconcerns,andIwanttodownsizemydataIloaded(withread_stata()youcannotonlyafe
I have RAM concerns, and I want to downsize my data I loaded (with read_stata()
you cannot only a few rows, sadly). Can I change the code below to use only some rows for X and y, but not make a copy? That would, even if temporarily defeat the purpose, I want to save on memory, not add ever more to my footprint. Or probably downsize the data first (does `reshape' do that without a copy if you specify a smaller size than the original?) and then pick some columns?
我有RAM问题,我想缩小我加载的数据(使用read_stata(),你不仅可以使用几行,遗憾的是)。我可以更改下面的代码,只使用X和y的某些行,但不能复制吗?即使暂时失败了,我也希望节省内存,而不是增加我的足迹。或者可能首先缩小数据的大小(如果指定的尺寸小于原始尺寸,那么“重塑”会不做副本吗?)然后选择一些列?
data = pd.read_stata('S:/data/controls/notreat.dta')
X = data.iloc[:,1:]
y = data.iloc[:,0]
1 个解决方案