我已经创建了很多数据帧作为预处理的一部分。由于我限制了6 6GB的内存,我想从内存中删除所有不必要的数据帧,以避免在scikit-learn中运行GRIDSEARCHCV时耗尽内存。
1)是否有一个函数可以只列出当前加载到内存中的所有数据帧?
我尝试了dir(),但它提供了许多数据帧以外的其他对象。
2)我创建了一个要删除的数据帧列表
del_df=[Gender_dummies,
capsule_trans,
col,
concat_df_list,
coup_CAPSULE_dummies]
范围(&R)
for i in del_df:
del (i)
但它不会删
我想使用pandas数据帧中的第一列作为行索引,所以我尝试使用来实现,但这样做的副作用是添加了额外的列索引。
(运行选项InteractiveShell.ast_node_interactivity = "all"的jupyter notebook代码):
import pandas as pd
df = pd.DataFrame([[l+r*10 for l in range(1, 5)] for r in range(1, 5)])
df # before
df.set_index(0, inplace=True)
df # after
set_index()之前的
R的新知识。我希望从数据帧中删除某些单词。因为有多个单词,所以我想将这个单词列表定义为一个字符串,并使用gsub删除。然后转换回数据帧并保持相同的结构。
wordstoremove <- c("ai", "computing", "ulitzer", "ibm", "privacy", "cognitive")
a
id text time username
1 "ai and x" 10
我正在用熊猫阅读一个excel文件。我想从原始数据帧创建多个数据帧。每个数据帧名都应该是第1行标题。此外,如何跳过每个事务之间的一列。
预期结果:
transaction_1:
name id available capacity completed all
transaction_2:
name id available capacity completed all
transaction_3:
name id available capacity completed all
我试过的是:
import pandas as pd
import pprint as pp
pd.option
我使用Python语言中的PyMongo库在MongoDB中插入文档。pandas数据帧有37个字段和60k条记录(数据集链接:)。数据帧中的所有字段都已转换为str类型。我收到以下错误:
OverflowError: MongoDB can only handle up to 8-byte ints
当我使用for循环插入2500个文档的块时,错误仍然存在。
代码片段:
import pandas as pd
import pymongo
client = pymongo.MongoClient()
db = client['patenting_in_psi']
colle
我有一个R数据帧,我使用下面的代码运行了一个R数据帧:
knit('reportTemplate.Rnw', 'file.tex') # creates a .tex file from the .Rnw one
texi2pdf('file.tex') # creates a .pdf file from the .tex one
在我的R脚本中,我想之后从我的计算机文件夹中删除'file.tex‘。我该如何实现这一点?在.R文件中执行此操作非常重要,因为这些行实际上位于从该模板生成1000个不同