我需要导入大型数据集并合并它们。我知道还有其他类似的问题,但我找不到具体问题的答案。使用dask,我似乎能够将大型数据集读入数据格式,但我无法将其与另一个数据格式合并。
import dask.dataframe as dd
import pandas as pd
#I have to do this with dask since with pandas I get mem issue and kills the python
ps = dd.read_csv('*.dsv',sep='|',low_memory=False)
mx = dd.read_csv('test.csv',sep='|',low_memory=False)
# this is where I get the error
mg = pd.merge(ps,mx,left_on='ACTIVITY_ID',right_on='WONUM')
ValueError: can not merge DataFrame with instance of type <class 'dask.dataframe.core.DataFrame'>很明显,它不能合并达斯克数据和熊猫的数据,但我还能怎么做呢?我可以使用pySpark或任何其他方法吗?
发布于 2017-10-15 18:47:11
@JohnE是对的-- dataframes有一个合并方法,这个方法(并非巧合)非常类似于熊猫一号;因此,既然您似乎需要内部合并,那么您应该简单地这样做:
mg = ps.merge(mx,left_on='ACTIVITY_ID',right_on='WONUM') # how='inner' by default, just as in pandas如果你想把达斯克的数据转换成熊猫的数据,达斯克from_pandas 方法也可能是有用的。
https://stackoverflow.com/questions/46757862
复制相似问题