This is my first time trying to do coding in Python, so I learned how to make a numpy array, and how I can export it as CSV file using np.savetxt. But, when I open the CSV file in excel, the columns of my matrix seems to be merged in one and it is impossible to do analysis on it. I was wondering how I can fix this issue. I don't know whether numpy is a proper choice for doing this analysis or not. So, if you have any other suggestions, please include.
Here, I have created an empty array with a1, b1 dimensions.
# Create an empty array with dim = (a1: num of months, b1:num of stations)
aa = np.empty((a1, b1))
aa[:] = np.nan
Here, I have filled the empty array row by row with a for loop:
for i in range(1, a1):
S_Obs = Sta_M.iloc [i-1, 2]
R_Val = Rad_M.iloc [i, 2:]
addadjuster = adjust.AdjustAdd(coords, coords, nnear_raws = 5)
addadjusted = addadjuster(S_Obs, R_Val)
aa[i,:] = addadjusted
Finally, when I display my array row by row, it looks like this:
aa[111, :]
array([ nan, nan, nan, 16.296, 24.888, nan, nan, nan,
nan, nan, nan, nan, nan, nan, 23.496, 1.704,
52.32 , nan, 25.368, nan, nan, nan, nan, nan,
nan, nan, nan, 21.264, 19.584, 22.272, 0.144, 10.008,
1.68 , 0. , nan, nan, nan, nan, nan, 0. ,
0. , 30.696, nan, nan, 24.888, nan, nan, 3.648,
14.832, 7.944, nan, nan, nan, nan, nan, nan,
nan])
I want to save this array in a way that I can do some simple analysis on it. It can be in EXCEL or CSV. I used this code, but it doesn't show the columns properly.
np.savetxt("AAtest.csv", aa, delimiter="/")
savetxtdocumentation have your tried? That is the standardnumpywriter for this task.