在两个数据范围之间查找

发布于 2025-02-05 15:48:41 字数 550 浏览 1 评论 0 原文

我从API响应中有类似的数据框架:

”在此处输入图像说明”

但是,API可以给出更多变量,例如街道,方向等,因此,我需要从API响应中创建一个输出,该输出自动定义NULL 。如下示例

alt

为此,我创建了我在输出中想要的所有变量的列表,并尝试并匹配API响应数据帧与输出数据帧。

任何帮助将不胜

感激

I have a dataframe like below from an API response:

enter image description here

However, The API can give more variables like street, direction etc., So, I need to create an output from the API response which automatically define null. Example like below

enter image description here

For this I created a list of all the variables I want in the output and tried and match API response dataframe to the output dataframe.

Any help will be greatly appreciated

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放低过去 2025-02-12 15:48:41

iiuc使用 按列表,如果不存在列,则缺少值填充:

L = ['house','house_number',..., 'street', 'direction']
df = df1.reindex(L, axis=1)

IIUC use DataFrame.reindex by list, if column not exist is filled by missing values:

L = ['house','house_number',..., 'street', 'direction']
df = df1.reindex(L, axis=1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文