Skip to content

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…

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 interpre…

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? Ed…