首页 > 解决方案 > 为什么我只通过选择元组的第一个元素来将元组转换为 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]))

标签: dataframetuples

解决方案


推荐阅读