Python 使用带FOR循环的Pandas数据帧

Python 使用带FOR循环的Pandas数据帧,python,pandas,Python,Pandas,谢谢你的关注 我正在尝试修改Python脚本,以便从网站下载大量数据。我已经决定,考虑到将要使用的大量数据,我希望为此将脚本转换为Pandas。到目前为止,我有这个代码 snames = ['Index','Node_ID','Node','Id','Name','Tag','Datatype','Engine'] sensorinfo = pd.read_csv(sensorpath, header = None, names = snames, index_col=['Node', 'Ind

谢谢你的关注

我正在尝试修改Python脚本,以便从网站下载大量数据。我已经决定,考虑到将要使用的大量数据,我希望为此将脚本转换为Pandas。到目前为止,我有这个代码

snames = ['Index','Node_ID','Node','Id','Name','Tag','Datatype','Engine']
sensorinfo = pd.read_csv(sensorpath, header = None, names = snames, index_col=['Node', 'Index'])
for j in sensorinfo['Node']:    
     for z in sensorinfo['Index']:

    # create a string for the url of the data
    data_url = "http://www.mywebsite.com/emoncms/feed/data.json?id=" + sensorinfo['Id'] + "&apikey1f8&start=&end=&dp=600"
    print data_url
    # read in the data from emoncms
    sock = urllib.urlopen(data_url)
    data_str = sock.read()
    sock.close

    # data is output as a string so we convert it to a list of lists
    data_list = eval(data_str)
    myfile = open(feed_list['Name'[k]] + ".csv",'wb')

    wr=csv.writer(myfile,quoting=csv.QUOTE_ALL)
代码的第一部分为我提供了一个非常好的表格,这意味着我正在打开csv数据文件并导入信息,我的问题是:

所以我尝试用伪代码来实现这一点:

For node is nodes (4 nodes so far)
 For index in indexes
       data_url = websiteinfo + Id + sampleinformation
      smalldata.read.csv(data_url)
      merge(bigdata, smalldata.no_time_column)

这是我在这里的第一篇帖子,我尽量简短,但仍然提供了相关数据。如果我需要澄清任何事情,请告诉我。

在伪代码中,您可以执行以下操作:

dfs = []
For node is nodes (4 nodes so far)
   For index in indexes
      data_url = websiteinfo + Id + sampleinformation
      df = smalldata.read.csv(data_url)
      dfs.append(df)

df = pd.concat(dfs)

因为他的代码中缺少基本的步骤,所以他使用了psuedocode。如果他给出了完整的函数,我会很乐意为他编写它。我试图包括我认为可以让我的观点得到理解的步骤,而不会陷入整个脚本的泥潭。你希望看到哪些基本步骤?老实说,你想做什么还不清楚。我的列表解决方案对您有用吗?