简体   繁体   中英

Each element of list into a separate pandas data frame

I have a list of list with soil physical properties, each element of the list represents a different location. is there a way to save each element of the list as a separate pandas data frame. When I try to transform the complete list I get the error message: ValueError: Must pass 2-d input. shape=(1, 19, 18) ValueError: Must pass 2-d input. shape=(1, 19, 18)

Your list of lists is included in another list, if you slice it with [0,:,:] you'll resolve that error. However, there's not enough information in your question to completely ensure your load to separate dataframes will work. Here's an example of how to reshape to 2-d input:

In [1]: a = np.array([[[1,2,3],[4,5,6]]])

In [2]: a.shape
Out[2]: (1, 2, 3)

In [3]: a[0,:,:].shape  #2D array
Out[3]: (2, 3)

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