lookup

Returning a value if three columns match in excel

情到浓时终转凉″ 提交于 2019-11-28 06:31:04
问题 I have two excel sheets where I need to match three values to return a fourth. The similar columns are month, agent, and subdomain. The fourth column is called difference. 回答1: Concatenate would work, as per @MakeCents suggestion, but if you don't want a helper column, SUMPRODUCT would work. example: =SUMPRODUCT(--(A2:A12="d"),--(B2:B12="S"),--(C2:C12="Apr"),D2:D12) would search range A2:A12 for "d", B2:B12 for "S" and C2:C12 for "Apr", and return the value fom D2:D12 that corresponds to

MongoDB nested lookup with 3 levels

杀马特。学长 韩版系。学妹 提交于 2019-11-28 05:51:18
I need to retrieve the entire single object hierarchy from the database as a JSON. Actually the proposal about any other solution to achive this result would be highly appriciated. I decided to use MongoDB with its $lookup support. So I have three collections: party { "_id" : "2", "name" : "party2" } { "_id" : "5", "name" : "party5" } { "_id" : "4", "name" : "party4" } { "_id" : "1", "name" : "party1" } { "_id" : "3", "name" : "party3" } address { "_id" : "a3", "street" : "Address3", "party_id" : "2" } { "_id" : "a6", "street" : "Address6", "party_id" : "5" } { "_id" : "a1", "street" :

Working with dictionaries/lists in R

拥有回忆 提交于 2019-11-28 03:03:32
I have trivial question: I couldn't find a dictionary data structure in R, so I used list instead (like "word"->number) So, right now I have problem how to get the list of keys. Anybody knows? Yes, the list type is a good approximation. You can use names() on your list to set and retrieve the 'keys': > foo <- vector(mode="list", length=3) > names(foo) <- c("tic", "tac", "toe") > foo[[1]] <- 12; foo[[2]] <- 22; foo[[3]] <- 33 > foo $tic [1] 12 $tac [1] 22 $toe [1] 33 > names(foo) [1] "tic" "tac" "toe" > You do not even need lists if your "number" values are all of the same mode. If I take Dirk

Lookup Tables Best Practices: DB Tables… or Enumerations

白昼怎懂夜的黑 提交于 2019-11-28 02:57:10
If we have to store the available positions at a company (i.e. Manager, Team Lead, ... etc). What are the best practices for storing it? I have two opinions with comments... "sure, welcoming yours" Storing it as DB table with columns ID and Name, and deal with it using queries and joins. Storing it as Enum and forget about the DB table. In my opinion, I will choose the first solution if I have changing items. So that I won't hard code these options as Enum. I may choose the Enum solution, if I have no doubt that data won't change (for example, Gender: Male, Female). NOTE: I code in English,

Interpolating data from a look up table

拜拜、爱过 提交于 2019-11-27 22:57:01
read the look up table LUT = np.genfromtxt('test.out', delimiter=',', dtype=float) LUT: 12, 25, 136, 6743 13, 26, 139, 6786 14, 27, 142, 6791 15, 28, 145, 6789 Values to be read from the LUT are as follows: x1, x2, x3 = 12.5, 25.5, 137 Reading the neighboring two values in the LUT for each of the given values (3 columns), I have to linearly interpolate the results (4th column in LUT). The given values (x1, x2, x3) belongs to between 1st and 2nd row of the LUT. Based on this how to read the results between 1st and 2nd row? Given a list of coordinates coords where you want to interpolate, you

How can I see if a Perl hash already has a certain key?

戏子无情 提交于 2019-11-27 17:05:13
问题 I have a Perl script that is counting the number of occurrences of various strings in a text file. I want to be able to check if a certain string is not yet a key in the hash. Is there a better way of doing this altogether? Here is what I am doing: foreach $line (@lines){ if(($line =~ m|my regex|) ) { $string = $1; if ($string is not a key in %strings) # "strings" is an associative array { $strings{$string} = 1; } else { $n = ($strings{$string}); $strings{$string} = $n +1; } } } 回答1: I

FAST unique combinations (from list with duplicates) WITHOUT LOOKUPS

流过昼夜 提交于 2019-11-27 16:23:20
问题 I seems that in spite of the fact that there are online plenty of algorithms and functions for generating unique combinations of any size from a list of unique items, there is none available in case of a list of non-unique items (i.e. list containing repetitions of same value.) The question is how to generate ON-THE-FLY in a generator function all the unique combinations from a non-unique list without the computational expensive need of filtering out duplicates? Now as there is a bounty

Getting a full copy of the WHOIS database [closed]

…衆ロ難τιáo~ 提交于 2019-11-27 15:07:39
问题 I'm interested in getting access to a full WHOIS database in order to expand on a domain-profile project I'm working on. I know ARIN provides this database only to non-commercial researchers and every WHOIS provider I know of (including ARIN itself) has rate-limiting. I also know, however, some commercial services that already exist (like the registrant lookup section of domaintools.com, which can search for domains by registrant name) which are impossible unless the site has direct access to

What is the best data structure for storing a set of four (or more) values?

冷暖自知 提交于 2019-11-27 14:13:43
Say I have the following variables and its corresponding values which represents a record . name = 'abc' age = 23 weight = 60 height = 174 Please note that the value could be of different types ( string , integer , float , reference-to-any-other-object, etc). There will be many records (at least >100,000). Each and every record will be unique when all these four variables (actually its values ) are put together. In other words, there exists no record with all 4 values are the same. I am trying to find an efficient data structure in Python which will allow me to (store and) retrieve records

Replace specific values based on another dataframe

怎甘沉沦 提交于 2019-11-27 13:46:40
First, let's start with DataFrame 1 (DF1) : DF1 <- data.frame(c("06/19/2016", "06/20/2016", "06/21/2016", "06/22/2016", "06/23/2016", "06/19/2016", "06/20/2016", "06/21/2016", "06/22/2016", "06/23/2016"), c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2), c(149, 150, 151, 152, 155, 84, 83, 80, 81, 97), c(101, 102, 104, 107, 99, 55, 55, 56, 57, 58), c("MTL", "MTL", "MTL", "MTL", "MTL", "NY", "NY", "NY", "NY", "NY")) colnames(DF1) <- c("date", "id", "sales", "cost", "city") I also have DataFrame 2 (DF2) : DF2 <- data.frame(c("06/19/2016", "06/27/2016", "06/22/2016", "06/23/2016"), c(1, 1, 2, 2), c(9999, 8888, 777