如何使用Python Pandas读取和格式化Weblink.csv

2024-04-30 03:07:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习熊猫,并试图从晨星下载一个.csv与晨星API。在

这里提供了一些关于如何使用API的非常好的组合说明(尽管它们不是特定于Python的)。。。https://gist.github.com/hahnicity/45323026693cdde6a116

hahnicity在示例中使用的示例Web链接是: http://globalquote.morningstar.com/globalcomponent/RealtimeHistoricalStockData.ashx?ticker=F&showVol=true&dtype=his&f=d&curry=USD&range=1900-1-1|2014-10-10&isD=true&isS=true&hasF=true&ProdCode=DIRECT

我的代码是:

import pandas as pd    
path='http://globalquote.morningstar.com/globalcomponent/RealtimeHistoricalStockData.ashx?ticker=F&showVol=true&dtype=his&f=d&curry=USD&range=1900-1-1|2014-10-10&isD=true&isS=true&hasF=true&ProdCode=DIRECT'

df=pd.read_csv(path)

然而,返回的是胡言乱语。我不知道如何让熊猫以正确的专栏形式阅读本文?在

非常感谢任何帮助。提前谢谢你!在


Tags: csvcomapitruehttp示例tickermorningstar
1条回答
网友
1楼 · 发布于 2024-04-30 03:07:13

好吧,所以我不明白如何处理以.csv格式存储的Pandas。。。所以我决定改用Quandl。它解决了我的问题。在

import pandas as pd
df=pd.read_csv('https://www.quandl.com/api/v3/datasets/WIKI/<ticker_symbol>/data.csv?api_key=<api_key>')

这将返回相关股票代码的日终定价。在

您可以在此处找到文档并注册API密钥: (https://docs.quandl.com/docs/in-depth-usage)。在

相关问题 更多 >