Categories
Mastering Development

Creating custom/more distance of ticks x axis in ggplot R

Please find my code below: packages <- c("ggplot2", "dplyr", "quantreg", "officer","tidyverse","here","glue","rvg","viridis","scales") install.packages(setdiff(packages, rownames(installed.packages()))) lapply(packages, require, character.only = TRUE) data <- read.csv(file=’Spiderplot_data.csv’, header=TRUE) Progressed <- as.factor(data$Progression) Response <- as.factor(data$X) Response <- factor(data$X, levels = c("Progressive Disease", "Stable Disease", "Partial Response", "Complete Response")) highlight_df <- filter(data, Progression == 1) p <- ggplot() + geom_line( data, mapping = […]

Categories
Mastering Development

How can I “stack” a nested list in Python?

How can I reshape a nested list so that all the nested items are nested in the item prior? e.g. ex1 = [1, [2, 20], [3, 30], [4]] ex2 = [1, [2]] ex3 = [1] expected outputs would be like this: ex1 = [1, [2, 20, [3, 30, [4]]]] ex2 = [1, [2]] ex3 = […]

Categories
Mastering Development

Constraints in DocCplex on Python don’t work

I’m trying to solve an optimization problem, but when I insert this constraint it doesn’t work: ”’ mdl.add_constraints(isinstance(w[i]/5, int) == True for i in range(0,5)) ”’ where w is defined as follow : ”’ w = mdl.integer_var_list(5,5,30, ‘W’) ”’ Python generates this error : Expecting sequence of constraints, got: False at position 0 I tried […]

Categories
Mastering Development

Syntax Error: ‘return’ outside function: my indentations seem to be correct

So first of all im writing a program that will total up all of the values in a list / array and heres what i got so far def go( ann ): total = 0 for i in range(0,len(ann)): total = total+ann[i] return total print ( go( [-99,1,2,3,4,5,6,7,8,9,10,12345] ) ) print ( go( [10,9,8,7,6,5,4,3,2,1,-99] ) […]

Categories
Mastering Development

Plotly’s Heatmap from (x, y, z) data

I am trying to achieve a Plotly’s Heatmap. You can check the documentation in https://plotly.com/python/heatmaps/ One of the examples in the documentation is: import plotly.graph_objects as go fig = go.Figure(data=go.Heatmap( z=[[1, None, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]], x=[‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’], y=[‘Morning’, ‘Afternoon’, ‘Evening’], hoverongaps = […]

Categories
Mastering Development

How to get key from the value of dictionary

I have the following set of rules for grading system if 25 < score <= 30, grade = A. if 20 < score <= 25, grade = B. if 15 < score <= 20, grade = C. if 10 < score <= 15, grade = D. if 5 < score <= 10, grade = E. […]

Categories
Mastering Development

While unstacking, getting error ‘ValueError: Index contains duplicate entries, cannot reshape’

I have a dataframe on which I need to apply condition based on same values of rows in few columns and update other columns. Input Dataframe initialization: df = pd.DataFrame({ ‘exp’:[‘1y’,’1y’,’1y’,’1y’,’1y’,’1y’,’1y’,’1y’,’1y’,], ‘mat’:[‘1y’,’1y’,’1y’,’2y’,’2y’,’2y’,’1y’,’1y’,’1y’,], ‘reg’:[‘in’, ‘in’, ‘in’, ‘in’, ‘in’, ‘in’,’in’,’in’,’in’], ‘con’:[‘5w’,’5s’,’5c’,’5w’,’5s’,’5c’,’10w’,’10s’,’10c’], ‘pcon’:[‘w’,’s’,’c’,’w’,’s’,’c’,’w’,’s’,’c’], ‘val’:[2.5,0,-2.5,2.5,0,-2.5,5,0,-5], ‘rs’:[6, 10, 4, 12, 30, 6,30,25,10] }) df Input DataFrame: exp mat reg con […]

Categories
Mastering Development

Are there in this graph self-loop? And if yer how can i remove it and check the isomorphism with another graph that have not self-loop?

Hi all I am checking if G2 is a subgraph isomorphism of G1, If I plot them I can clearly see the isomorphism but if I use the function I can False. Anyone know why? I think that the reason are the self-loop in the rectangular graph but I don’t know how to remove them […]

Categories
Mastering Development

Arrange data frame columns by class

Good afternoon , Assume we have the following dataset : dput(head(cylinder)) structure(list(X19910108 = c("19910109", "19910104", "19910104", "19910111", "19910104", "19910111"), X126 = c("X266", "B7", "T133", "J34", "T218", "X249"), TVGUIDE = c("TVGUIDE", "MODMAT", "MASSEY", "KMART", "MASSEY", "ROSES"), X25503 = c(25503L, 47201L, 39039L, 37351L, 38039L, 35751L), YES = c("YES", "YES", "YES", "NO", "YES", "NO"), KEY = c("KEY", "KEY", […]

Categories
Mastering Development

Variable array creation using numpy operations

I wish to create a variable array of numbers in numpy while skipping a chunk of numbers. For instance, If I have the variables: m = 5 k = 3 num = 50 I want to create a linearly spaced numpy array starting at num and ending at num – k, skip k numbers and […]