Categories

## 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

## 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

## 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

## 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

## 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

## 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

## 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

## 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] = […]