I found this code at Stack Overflow: input_filename = "to_modify.xlsx" wb = load_workbook(input_filename) # Get first sheet sh: worksheet = wb[wb.sheetnames[0]] The link is here: How to change font size in Python OpenPyXL So, I tried in a simplified way as: str = [1, 2, 3, 4] bo: fo = str[str[0]] And it gave me […]
Tag: 2
In my df below, I want to : identify and flag the outliers in col_E using z-scores separately explain how to identify and flag the outliers using z-scores in two or more columns, for example col_D & col_E See below for the dataset import pandas as pd # intialise data of lists df = { […]
I am trying to reverse the same iterator several times, using the reversed function. For instance, with the code: iterator = range(3) N = 5 k = 0 out = [] while k < N: for i in iterator: out.append(i) iterator = reversed(iterator) k += 1 print(out) I would want/expect to have the output: [0, […]
#Data Import data<-read.csv("D:\\general\\insurance.csv") #Data Exploration(EDA) str(data) summary(data) #Data Preparation #Outlier Detection & Treatment #Box-Plot outlier_values <- boxplot.stats(data$charges)$out # outlier values par(mar=c(2,2,2,2)) boxplot(data$charges, main="charges", boxwex=0.1) mtext(paste("Outliers: ", paste(outlier_values, collapse=",")), cex=0.6) user defined function for creating descriptive statistics stats <- function(x) { iqr=IQR(x,na.rm=T) q1<-quantile(x,0.25,na.rm=T) q2<-quantile(x,0.5,na.rm=T) q3<-quantile(x,0.75,na.rm=T) UC<-q3+1.5*iqr LC<-q1-1.5*iqr min<-min(x,na.rm=T) max<-max(x,na.rm=T) return(c(q1=q1, q2=q2, q3=q3,UC=UC, LC=LC, min=min, max=max)) } […]
I have an array A with the shape (3,3) which can be thought of as the sliding window view of an unkown array with the shape (5,). I want to compute the inverse of windowing the array with the shape (5,). The adjoint operation of this will be summation. What I mean is that I […]
1 – I am extracting features for superpixels and one of the extractions that I need to implement is the extraction of Haralick features from the gray-level Co-occurrence Matrix GLCM (Gray-Level Co-occurrence Matrix). In this sense, I understood that first I have to extract Haralick and then apply it to GLCM to find the contrast, […]
a = np.array(list(range(16).reshape((4,4)) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) Say I want the middle square. It’d seem reasonable to do this: a[[1,2],[1,2]] but I get this: array([5, 10]) This works, but seems inelegant: a[[1,2],:][:,[1,2]] array([[5, 6], [9, 10]]) So my questions are: […]
I have two vectors x and y of coordinates and a 3D array A in R. I want to produce a matrix, where the i’th row is A[x[i], , y[i]]. If A was 2D, I believe I could use A[cbind(x,y)]. For the 3D array, I think the following works, but it’s kind of slow: sapply(1:length(x), […]
With std::array you can do std::array<int,3> v = {1,2,3}; But I want to provide a wrapper template <typename T, int n> circular_array { auto operator[](size_t i){ return m_data[i%n]; } // TODO forward all other methods directly except “at“ which we don’t need private: std::array<t,n> m_data; } but I lose the aggregate initialization that I had […]