Categories
Mastering Development

pandas merge as of on one column, exactly on other columns?

I am trying to merge 2 dataframes, with exact matching on some columns and as_of matching on some other column (typically a date). The intention is very well described in this post (I’ll copy paste the main content below): Pandas: Approximate join on one column, exact match on other columns The post above was answered […]

Categories
Mastering Development

Split dataframe with all values in one row

I got the following dataframe which is created dynamically but saves all the relevant values into one row: df +—————-+—————-+—————-+—————-+ | 1 | 2 | 3 | 4 | +—————-+—————-+—————-+—————-+ | a1, b1, c1, d1 | a2, b2, c2, d2 | a3, b3, c3, d3 | a4, b4, c4, d4 | +—————-+—————-+—————-+—————-+ I need to […]

Categories
Mastering Development

Filter dataframe by logic

I have this dataframe: MAT MAT_IN SER D8 0 X A1 Yes – 1 X A2 No X 2 X A3 No X 3 X A4 Yes X 4 Y B1 No – 5 Y B2 No – 6 Y B3 No – 7 Y B4 No – 8 Y B5 No – Where I […]

Categories
User Help Web Apps

Google Sheets look for string in area

I have in my sheet a list of names in every second line (A2, B2, C2, D2, A4, B4, C4, D4, A6, and so on) and those names can appear in 1 of 4 areas(e.g. H3:I13 or K3:L13) in the same sheet. Now I want to change the background color of the names in the […]

Categories
User Help Web Apps

Google Sheets look for string in area

I have in my sheet a list of names in every second line (A2, B2, C2, D2, A4, B4, C4, D4, A6, and so on) and those names can appear in 1 of 4 areas(e.g. H3:I13 or K3:L13) in the same sheet. Now i want to change the background color of the names in the […]

Categories
Mastering Development

How to make custom code in python utilize GPU while using Pytorch tensors and matrice functions

I’ve created a CNN from scratch only using Pytorch tensors and matrix operation functions in the hope of utilizing GPU. To my surprise, the GPU stays 0% utilized and my training doesn’t seem to be faster than running on my cpu. CODE: import operator from pathlib import Path from IPython.core.debugger import set_trace from fastai import […]

Categories
Mastering Development

how to concat and combine two rdd into one in PySpark

I get two RDD and want to concat and combine into one RDD as follows: rdd_1 = [‘a1’, ‘a2’, ‘a3’, ‘a4’, ‘a5’, ] rdd_2 = [‘b1’, ‘b2’, ‘b3’, ‘b4’, ‘b5’, ] # concat and combine these two rdd into one rdd = [‘a1_b1’, ‘a2_b2’, ‘a3_b3’, ‘a4_b4’, ‘a5_b5’] I know I could convert these two RDD […]

Categories
Mastering Development Software

Can’t break this loop. Please help!

I am using this script to play notes on a Piezo in Python, but need help making it stop. Here is the full code, it is still a work in progress. A lot of it is probably irrelevant to the problem, but I’m a in a bit over my head right now so maybe you […]

Categories
Mastering Development

How to extract row before and after when flag change from 0 to 1

I have one dataframe , i want to extract 2 rows before flag change from 0 to one and get row where value ‘B’ is minimum , also extract two rows after flag 1 and get row with minimum value of ‘B’ df=pd.DataFrame({‘A’:[1,3,4,7,8,11,1,15,20,15,16,87], ‘B’:[1,3,4,6,8,11,1,19,20,15,16,87], ‘flag’:[0,0,0,0,1,1,1,0,0,0,0,0]}) df_out=pd.DataFrame({‘A’:[4,1], ‘B’:[4,1], ‘flag’:[0,1]})

Categories
Mastering Development

Plot data.tree coloring and labelling by level

I have the following data.tree structure. d <- structure(list(SUBZONE = c(“A1”, “A2”, “A3”, “A4”, “A8”, “B10”, “B11”, “B2”, “B3”, “B4”), ZONE = c(“A”, “A”, “A”, “A”, “A”, “B”, “B”, “B”, “B”, “B”), ID = c(1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L)), .Names = c(“SUBZONE”, “ZONE”, “ID”), row.names = c(NA, 10L), class = […]