Categories
Mastering Development

Fast way to remove array of specific row values from 2D numpy array

I have a 2D array like this: a = np.array([[25, 83, 18, 71], [75, 7, 0, 85], [25, 83, 18, 71], [25, 83, 18, 71], [75, 48, 8, 43], [ 7, 47, 96, 94], [ 7, 47, 96, 94], [56, 75, 50, 0], [19, 49, 92, 57], [52, 93, 58, 9]]) and I want to […]

Categories
Mastering Development

dataframe does not change after sorting

I have a dataframe which I need to sort it first and then do some manipulation on it. However after the following snipped code the dataframe (result ) does not change and I should save the result in a csv file to have the changes. result.sort_values(["y", "x"], axis=0, ascending=True, inplace=True, na_position=’last’) result = result.copy(deep=True) Why […]

Categories
Mastering Development

I want to check if all values in one column of a dataset are bigger than the means of that column

I want to check all values in a column against one value(means) of the same column and then split into two lists. means = np.mean(X[0], axis=0) X = df.iloc[:, :4] How can I check if values of X[0] are <= or > than the mean and split these values into two? print(X.head(5)) print(np.mean(X[0].head(5),axis=0))

Categories
Mastering Development

implementing python code on GPU using numba

so I have a function that work on cpu in order to make some computation on an image data set but the data is too big therefore I’ve decided to run it on the gpu using numba the function is below : from numba import jit , cuda @jit(target="cuda") def create_celebahq_cond(tfrecord_dir, celeba_dir, delta_dir, num_threads=4, num_tasks=100, […]

Categories
Mastering Development

Converting very large 3D Python list to numpy array never finishes

I have a very large 3D Python list (1486x4656x34) of floating point numbers, which I need to compute the mean along axis 0 (to yield a 4656×34 result). I have attempted to do this with np.mean(arr, axis=0), but the method never seems to complete its execution (or if it does, it takes more time than […]

Categories
Mastering Development

how to drop a categorical value from a data frame column in python?

I am working with a data frame title price_df. and I would like to drop the rows that contain ‘4wd’ from the column drive-wheels. I have tried price_df2 = price_df.drop(index=’4wd’, axis=0) and a few other variations after reading the docs pages in pandas, but I continue to get error codes. Could anyone direct me to […]

Categories
Mastering Development

Sorting a column with boolean values which are grouped

my first time here so im sorry for errors or mistakes. i have this df which is grouped and count of boolean in each group. i want to sort the ‘occurrence’ in descending order while remaining grouped by state and booleans property_state delinquency occurrence AK False 119 True 17 AL False 928 True 185 AR […]

Categories
Mastering Development

Multilabel classification with imbalanced dataset

I am trying to do a multilabel classfication problem, which has an imabalnced dataset. The total number of samples is 1130, out of the 1130 samples, the first class occur in 913 of them. The second class 215 times and the third one 423 times. In the model architecture, I have 3 output nodes, and […]

Categories
Mastering Development

How can I keep the association between image and coordinate (z-axis) after a preprocess function?

I’m working on a preprocessing function that takes DICOM files a input and returns a 3D np.array (image stack). The problem is that I need to keep the association between ImagePositionPatient[2] and the relative position of the processed images in the output array. For example, if a slice with ImagePositionPatient[2] == 5 is mapped to […]

Categories
Mastering Development

Choropleth map – no color differentiation

I’m trying to create a choropleth map based on rates of unaffordable housing for Toronto neighborhood. I found a dataset online which I read in a a csv, then conditioned data to make appropriate columns, and then attempted to create my map. My code for the data and conditioning looks like this: df = pd.read_csv(‘torontodata.csv’) […]