Skip to content
Advertisement

Tag: numpy

Creating 3d Tensor Array from 2d Array (Python)

I have two numpy arrays (4×4 each). I would like to concatenate them to a tensor of (4x4x2) in which the first ‘sheet’ is the first array, second ‘sheet’ is the second array, etc. However, when I try np.stack the output of d[1] is not showing the correct values of the first matrix. Answer If you do np.dstack((x, y)), which

pd.dataframe saving only one line

Hi i’m wondering what should i do to save all those values in a dataframe… already tried to save each one separately but it wont came up.. i needed to save all printed values in a dataframe, thats for 304 images (304 lines) buts it only saves the last line can someone help me? Answer You are overwriting and saving

Begginer/ numpy where and copy

I am trying to copy values from one Field2 into Field1 if Field1 is null or NaN. I have tried below where statement as per documentation, but it cuts outliners instead of copyting the value. dataframe=np.where(dataframe[‘field1’].isnull(),np.copy(dataframe[‘field2’]),1) I have interpreted it as if statement, but apparently its wrong interpretation, as results are not correct. Has anyone of you had similar issues?

How to resample a dataframe an include start and end times?

So I am working with tick data and I am attempting to resample the dataframe to minute bars, but when resample is called the time series begins and ends the first instance that a tick exists. How would I resample this data such that the first and last times can be specified to a certain start and end time? Edit

Advertisement