Pandas/Geopandas 与蒙版选择合并
我通常使用 Arcpy,但我正在尝试了解更多 pandas/geopandas 的用途。我有一个应用于 csv 表和 shapefile 的掩码,我想将其合并在一起,以便根据特定字段查找两者之间的匹配项。
然而,当我尝试将它们合并在一起时,我收到错误“数据框的真值不明确”。如何合并屏蔽数据框?我在下面添加了创建掩码(利用两个日期变量和一个日期字段)的代码段以及使用位置字段(每个数据帧上的不同名称)的合并。
我需要做什么才能操作掩码数据帧使其在掩码中发挥作用?
mask = (svc_df['createdate'] < curdate) & (svc_df['createdate'] >= backdate)
print(svc_df.loc[mask])
# Detect the sub-dataframe and then assign to a new dataframe
sel_df = svc_df.loc[mask]
#Create a geodf from alabama services
al_gdf = geopandas.read_file(alSvc_shp)
al_merge = al_gdf.merge(al_gdf, sel_df, left_on="Location", right_on="sketch_LOC")
I usually work with Arcpy but am trying to learn more pandas/geopandas uses. I have a mask applied to a csv table and a shapefile that I want to merge together in order to find matches between the two based on a specific field.
However, when I try to merge them together, I get the error "The truth value of a Dataframe is ambiguous." How do I merge a masked dataframe? I've included the segment of code below that creates the mask (utilizing two date variables and a date field) and the merge which uses the Location fields (different names on each dataframe).
What do I need to do to manipulate the mask dataframe into functioning in a mask?
mask = (svc_df['createdate'] < curdate) & (svc_df['createdate'] >= backdate)
print(svc_df.loc[mask])
# Detect the sub-dataframe and then assign to a new dataframe
sel_df = svc_df.loc[mask]
#Create a geodf from alabama services
al_gdf = geopandas.read_file(alSvc_shp)
al_merge = al_gdf.merge(al_gdf, sel_df, left_on="Location", right_on="sketch_LOC")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
dataframe.merge()
而不是pd.merge()
因此只有一个数据框应该作为 下面的参数dataframe.merge()
notpd.merge()
hence only one data frame should be passed as a parameter