dataframe - 为什么我只通过选择元组的第一个元素来将元组转换为 DataFrame?
问题描述
我很困惑为什么我通过意外选择元组的第一个元素将元组转换为 DataFrame。我打算检查元组的第一个元素,但后来发现输出已经是一个 DataFrame。选择第一个元素是一种将元组转换为 DataFrame 的方法吗?我搜索了互联网,并没有将其视为一种方法。谢谢您的帮助!
以下是代码:
import pandas as pd
import numpy as np
import earthpy as et
import hydrofunctions as hf
# Define the site number and start and end dates that you are interested in
site = "06730500"
start = '1946-05-10'
end = '2018-08-29'
# Request data for that site and time period
longmont_resp = hf.get_nwis(site, 'dv', start, end)
# Convert the response to a json in order to use the extract_nwis_df function
longmont_resp = longmont_resp.json()
longmont_discharge = hf.extract_nwis_df(longmont_resp)
print(longmont_discharge)
print (type(longmont_discharge))
print(type(longmont_discharge[0]))
解决方案
推荐阅读
- python - 迭代未来结果时,如何获取发送给 ThreadPoolExecutor 的参数?
- vim - 如何一次查看所有 vim :help 内容/文件/主题/主题?
- eclipse - 开发 Jenkins 的共享库时,如何在 Eclipse 中获得正确的语法突出显示?
- python - (聊天室)通常只允许一个地址使用一个套接字(协议/网络地址/端口)
- postgresql - 从 Neomodel Django 连接到 AWS PostgreSQL
- ruby-on-rails - Stripe 结帐后设置电子邮件的语言
- java - 在Java中提取正则表达式内部值
- postgresql - 删除函数将删除的记录存储为 json
- tensorflow - ValueError: 层 cu_dnnlstm 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。收到的完整形状:[无,175]
- django - 这是使用 django rest 框架将帖子添加到收藏夹的正确方法吗?