Create a new column with the text of another column between parentheses

I am new to Power BI and I am trying to create a new table column based on the values of an actual column in the table, between parentheses. Actual column = Frankfurt (FRA) New Column = FRA Can somebody help me please? >Solution : In PowerQuery, select your actual column, then go to Add… Read More Create a new column with the text of another column between parentheses

Pandas different mathematical operation, conditional on column value

data= {‘start_value’:[10,20,30,40,50,60,70], ‘identifier’:[‘+’,’+’,’-‘,’-‘,’+’,’-‘,’-‘]} df = pd.DataFrame(data) start_value identifier 0 10 + 1 20 + 2 30 – 3 40 – 4 50 + 5 60 – 6 70 – I am attempting to created a new column "end_value" that results in either +5 or -5 to the *"*start_value" column based on the "+" or "-"… Read More Pandas different mathematical operation, conditional on column value

Error on creating conditional column in R

Thank you for your kind responses. I have a dataframe and I need to apply a formula over a columns depending of the value of other column: data <- data.frame(figure = c("square","square","circle","square","circle"), diameter =c(NA,NA,21,NA,12), side=c(32,27,NA,51,NA)) What I need is to calculate the area according the square or circle formula (square = side * side, circle=… Read More Error on creating conditional column in R

Calculating row sums in data frame based on column names

I have a data frame with media spending for different media channels: TV <- c(200,500,700,1000) Display <- c(30,33,47,55) Social <- c(20,21,22,23) Facebook <- c(30,31,32,33) Print <- c(50,51,52,53) Newspaper <- c(60,61,62,63) df_media <- data.frame(TV,Display,Social,Facebook, Print, Newspaper) My goal is to calculate the row sums of specific columns based on their name. For example: Per definition Facebook… Read More Calculating row sums in data frame based on column names

Django count and store values in models

I have multiple Models which look like this class Classes(models.Model): User = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) A1 = models.IntegerField(default=0) B1 = models.IntegerField(default=0) etc A2 = models.IntegerField(default=0) B2 = models.IntegerField(default=0) etc A3 = models.IntegerField(default=0) B3 = models.IntegerField(default=0) etc A4 = models.IntegerField(default=0) B4 = models.IntegerField(default=0) etc Sum_of_1 = models.IntegerField( blank=True, null=True) Sum_of__2 = models.IntegerField( blank=True, null=True) Sum_of__3 =… Read More Django count and store values in models

Creating A New Calculated Category Within A Column in R

Suppose I have a data frame similar to this, only with 1000’s of observations: df <- data.frame(Group = c(‘A’, ‘A’, ‘A’, ‘B’, ‘B’, ‘B’,’B’,’C’,’C’,’C’,’D’,’D’,’D’,’D’,’D’), Values=c(‘5′,’7′,’9′,’0′,’8′,’4′,’5′,’2′,’1′,’3′,’6′,’3′,’1′,’3′,’5’)) What I want to do is add a new calculated group to the data frame based on values in a group that already exists in the data frame without replacing… Read More Creating A New Calculated Category Within A Column in R