Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pandas 将gziped csv导入到熊猫中_Pandas_Pandas Datareader - Fatal编程技术网

Pandas 将gziped csv导入到熊猫中

Pandas 将gziped csv导入到熊猫中,pandas,pandas-datareader,Pandas,Pandas Datareader,我有一个网址: 这是我从url获取数据并写入excel的代码 import pandas as pd url = "https://api.kite.trade/instruments" df = pd.read_json(url) df.to_excel("file.xlsx") print("Program executed successfully") 但是,当我运行这个程序时,我得到了这样的错误_ AttributeErro

我有一个网址:

这是我从url获取数据并写入excel的代码

import pandas as pd

url = "https://api.kite.trade/instruments"
df = pd.read_json(url)
df.to_excel("file.xlsx")
print("Program executed successfully")
但是,当我运行这个程序时,我得到了这样的错误_

AttributeError: partially initialized module 'pandas' has no attribute 'read_json' (most likely due to a circular import)

它不是json,而是csv。因此,您需要使用
读取\u csv
。你能试试这个吗

import pandas as pd

url = "https://api.kite.trade/instruments"
df = pd.read_csv(url)
df.to_excel("file.xlsx",index=False)
print("Program excuted successfully")

我添加了一个示例,说明如何将文本转换为本地驱动器上的csv转储

import requests

url = "https://api.kite.trade/instruments"
filename = 'test.csv'

f = open(filename, 'w')
response = requests.get(url)
f.write(response.text)

显示此错误属性错误:部分初始化的模块“pandas”没有“read_csv”属性(很可能是由于循环导入)。您是否使用与上述相同的代码?如果是,请尝试将csv下载到桌面并将其重命名为其他名称,如my_csv.csv。看起来pandas对导入的内容感到困惑。意思是pip安装csvNo,安装这个并放到同一个目录中:“