Categories
Linux Mastering Development

Editing a file based on a pattern appearance

I have a file that contains text and numbers like this: state(1, s(1,a), [s(1,b)]). state(1, s(1,b), [s(1,a)]). state(1, s(2,a), [s(2,b)]). state(1, s(2,b), [s(2,a)]). state(1, s(3,a), [s(3,b)]). state(1, s(3,b), [s(3,a)]). state(1, s(4,a), [t(1), t(2)]). state(1, s(5,a), [t(1), t(3)]). state(1, s(6,a), [s(6,b)]). state(1, s(6,b), [s(6,a)]). …so on I want the numbering with in s(x,y) to change as […]

Categories
Mastering Development

How to calculate the angles between each two successive lines in polygon

I tried to calculate the angles between each two successive lines in the polygon using the law of Cosines: $ cos(C) = \frac{a^2+b^2-c^2}{2ab} $, but I’m getting the Error: ValueError: math domain error, because the value of the cos obtained from that rule was out of range [-1, +1]. can you please advise me how […]

Categories
User Help

Return blank cell if other cells have content

I would like to return a blank cell if either cells O2 or P2 are blank. Both O2 and P2 have a formula linking to another cell. Each thing that I try seems to put a number in my cell even when O2 or P2 are populated. Cell A2 has a date, so if O2 […]

Categories
Mastering Development

create nested JSON from Pandas DataFrame with grouped rows as attributes inside deepest nest

I’m looking for a solution to build a nested dict / JSON with the last three columns "name", "color", "amount" as attributes inside a "products" list. The values from the cat1-cat3 columns should be the keys. The provided DataFrame looks like this: import pandas as pd df = pd.DataFrame({ ‘cat1’: [‘A’, ‘A’, ‘A’, ‘B’, ‘B’, […]

Categories
User Help

Can Excel autofill one range but copy another in the same autofill operation?

I have a table in Excel which I need to copy 80 times, and have each one be numbered sequentially. (Table 1, Table 2, Table 3 … Table 80) However, one of the columns in this table contains the text (P1, P2, P3, P4, P5, P6). When I drag the autofill thing down to copy […]

Categories
Mastering Development

String comparison in Databricks Spark SQL

select distinct promo_name ,case when substring(promo_name,instr(promo_name, "P0"),2) = "P0" then 0 when substring(promo_name,instr(promo_name, "P1"),2) = "P1" then 1 When substring(promo_name,instr(promo_name, "P01"),3) = "P01" then 1 when substring(promo_name,instr(promo_name, "P2"),2) = "P2" then 2 When substring(promo_name,instr(promo_name, "P02"),3) = "P02" then 2 when substring(promo_name,instr(promo_name, "P3"),2) = "P3" then 3 when substring(promo_name,instr(promo_name, "P03"),3) = "P03" then 3 when substring(promo_name,instr(promo_name, […]

Categories
Mastering Development

How to convert data to log10 while ignoring or removing the values of 0?

The code I’m using: pay3 = [‘P1’, ‘P2’, ‘P3’, ‘P4’, ‘P5’, ‘P6’] logs = np.log10(df[pay3]) So my "pay3" variable is a group of 6 columns from my data frame. All of the data are integers. I’m trying to convert the data in those columns to a log10, and I also need to ignore the values […]

Categories
Mastering Development

R conditional loop to replace vallues

I am looking to conditionally replace values in a column and I think a loop is what I need. Though I know on a basic level how loops work, I have little experience using them so I struggle with wrapping my head around the order of operations. Using the dataframe df <- structure(list(player = c(“p1”, […]

Categories
Mastering Development

Not able to view the drop down options in rails UI

Below code snippet is a case add form where it shows the select tag in UI but if it is clicked on its arrow button nothing is viewed, in-browser console it shows all the select options. <div id=”addCaseForm” style=”display:none”> <%= form_tag(“#{@view.addUrl}”, method: “post”) do %> <div class=”row padlef”> <div class=”col-sm-8″> <div class=”form-group”> <%= label_tag(“Case Title:”) […]

Categories
Mastering Development

Replace underscore with white spaces and make the first letter of the name and the surname to upper case

i want to replace _ (underscore) with white spaces and make the first letter of the name and the surname to upper case while printing the nameList in searchKeyword method. #include <stdio.h> #include <stdlib.h> #include <string.h> void searchKeyword(const char * nameList[], int n, const char keyword[]) { int i,name=0; char *str; const char s[2] = […]