Untitled
unknown
plain_text
12 days ago
522 B
3
Indexable
import numpy as np import pandas as pd # Example 3D matrix (shape: depth=3, rows=2, columns=2) arr_3d = np.array([ [[1, 2, 3, 4], [5, 6, 7, 8]], [[11, 12, 13, 14], [15, 16, 17, 18]], [[21, 22, 23, 24], [25, 26, 27, 28]] ]) # Save each 2D slice as a separate Excel sheet with pd.ExcelWriter("ohlc.xlsx") as writer: for i in range(arr_3d.shape[0]): # Iterate over depth (first dimension) df = pd.DataFrame(arr_3d[i]) df.to_excel(writer, sheet_name=f"expiry_{i}", index=False, header=False)
Editor is loading...
Leave a Comment