我有四个URL的列表,我试图遍历这些URL并将它们作为DataFrame读入Pandas。问题在于它只会读取一个.csv文件。
以下是我的代码:
#Import necessary libraries
import pandas as pd
import time
#URL's for weekly projections on rotogrinders.com
url =['https://rotogrinders.com/projected-stats/nfl-qb.csv?site=draftkings',\
'https://rotogrinders.com/projected-stats/nfl-rb.csv?site=draftkings',\
'https://rotogrinders.com/projected-stats/nfl-wr.csv?site=draftkings',\
'https://rotogrinders.com/projected-stats/nfl-te.csv?site=draftkings']
#Loop through each url, read the .csv into a DataFrame,append all together,
#then write the DataFrame to a .csv file
file_name = 'weekly_projections_'
timestr = time.strftime('%Y%m%d')
df = pd.DataFrame()
for data in url:
df = pd.read_csv(data)
df.append
df.to_csv(file_name + timestr + '.csv')
当我通过时。 info()您可以看到我只得到结果的1/4。我希望会有200多个条目
df.info
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 28 entries, 0 to 27
Data columns (total 8 columns):
Baker Mayfield 28 non-null object
5400 28 non-null int64
CLE 28 non-null object
QB 28 non-null object
ATL 28 non-null object
30.18435 28 non-null float64
9.81225 28 non-null float64
18.69 28 non-null float64
dtypes: float64(3), int64(1), object(4)
memory usage: 1.8+ KB
有人有建议吗?
答案 0 :(得分:0)
您可以通过<input type="radio" name="radio-check" selected='selected' class="radio-large" >
<input type="radio" name="radio-check" class="radio-large" >
循环执行以下操作:
在开头声明一个空的数据框:
for
让我知道这是否是您想要的。