python, pd.read_csv ripetitive importation

后端 未结 1 1549
小鲜肉
小鲜肉 2021-01-24 07:31

I need to import with

 pd.read_csv

a repetitive importation as at first time I import

node_t1 = pd.read_csv(\'5mins/nodes/N12         


        
相关标签:
1条回答
  • 2021-01-24 08:01

    That can be done using a formatted string and a loop like:

    def read_nodes(node_number):
        n1 = pd.read_csv('5mins/nodes/N%d' % node_number)
        n2 = pd.read_csv('10mins/nodes/N%d' % node_number)
        n3 = pd.read_csv('15mins/nodes/N%d' % node_number)
        return n1, n2, n3
    
    
    for i in range(150):
        node_t1, node_t2, node_t3 = read_nodes(i)
    
        # process nodes for node i here
        ....
    
    0 讨论(0)
提交回复
热议问题