简体   繁体   中英

2d array function months

I have monthly data of 25 total years. I split the monthly data in Januarys, Februarys, etc. to have 25 points each (so each month for the 25 years). Then in order to rebuild the original data array, a function was made:

def merge_months(split_data):
    merged_months = []
    for value in range(split_data.shape[1]):
        for month in range(split_data.shape[0]):
            merged_months.append(split_data[month][value])
    return merged_months

You can simply implement the function in a loop so the function is applied 6 times to reshuffle the (12,25) data:

merged_3d = []
for i in range(len(multi_dim_array)): #multi_dim_array being your (6,12,25) data
    merged_3d.append(merge_months(multi_dim_array[i]))

This returns (6,300) shaped data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM