outer-join

R pairwise product

安稳与你 提交于 2019-12-01 17:34:20
问题 I'm trying to get the pairwise products of a vector, say a = c(1,2,3,4) What I'm trying to get is 2,3,4,6,8,12 (in that order). I've tried using outer: outer(1:4,2:4) and that gives me a matrix that includes the products I want but I'm not sure how to extract them from the matrix in a way that scales to vectors of higher dimensions. Thanks! 回答1: combn() is nice for this sort of thing: a <- 1:4 combn(a, m = 2, FUN = prod) # [1] 2 3 4 6 8 12 回答2: lower.tri selects them in that order: out <-

Workaround for outer join with an IN operator in Oracle

醉酒当歌 提交于 2019-12-01 06:52:08
I am using Oracle SQL, so outer joins have the nice (+) syntax. I should warn you that I am not allowed to redesign the database; I work for a large organization. Here are some example tables: People PersonID Name 1 Elmo 2 Oscar 3 Chris Attribute PersonID Attribute 1 Happy 1 Muppet 1 Popular 2 Grouchy 2 Muppet 2 Popular 3 Programmer I want a list of people and I want to know whether we have knowledge of them being happy or grouchy. The following is the output I want: Name Mood Elmo Happy Oscar Grouchy Chris So here is the query I thought I would use: SELECT p.Name, a.Attribute FROM People p,

Outer merging two data frames in place in pandas

时光怂恿深爱的人放手 提交于 2019-12-01 03:48:37
How can I outer merge two data frames in place in pandas? For example, assume we have these two data frames: import pandas as pd s1 = pd.DataFrame({ 'time':[1234567000,1234567005,1234567009], 'X1':[96.32,96.01,96.05] },columns=['time','X1']) # to keep columns order s2 = pd.DataFrame({ 'time':[1234567001,1234567005], 'X2':[23.88,23.96] },columns=['time','X2']) # to keep columns order They could be merged with pandas.DataFrame.merge ( s3 = pd.merge(s1,s2,how='outer') ) or with pandas.merge ( s3=s1.merge(s2,how='outer') ), but it isn't in place. Instead, I'd like the merged data frame to replace

Outer join in Clojure

非 Y 不嫁゛ 提交于 2019-12-01 03:46:27
Similar to this question: Inner-join in clojure Is there a function for outer joins (left, right and full) performed on collections of maps in any of the Clojure libraries? I guess it could be done by modifying the code of clojure.set/join but this seems as a common enough requirement, so it's worth to check if it already exists. Something like this: (def s1 #{{:a 1, :b 2, :c 3} {:a 2, :b 2}}) (def s2 #{{:a 2, :b 3, :c 5} {:a 3, :b 8}}) ;=> (full-join s1 s2 {:a :a}) ; ; #{{:a 1, :b 2, :c 3} ; {:a 2, :b 3, :c 5} ; {:a 3, :b 8}} And the appropriate functions for left and right outer join, i.e.

Outer join in Clojure

荒凉一梦 提交于 2019-12-01 00:19:30
问题 Similar to this question: Inner-join in clojure Is there a function for outer joins (left, right and full) performed on collections of maps in any of the Clojure libraries? I guess it could be done by modifying the code of clojure.set/join but this seems as a common enough requirement, so it's worth to check if it already exists. Something like this: (def s1 #{{:a 1, :b 2, :c 3} {:a 2, :b 2}}) (def s2 #{{:a 2, :b 3, :c 5} {:a 3, :b 8}}) ;=> (full-join s1 s2 {:a :a}) ; ; #{{:a 1, :b 2, :c 3} ;

End-of-window outer join with KafkaStreams

泪湿孤枕 提交于 2019-11-30 22:11:45
I have a Kafka topic where I expect messages with two different key types: old and new. i.e. "1-new" , "1-old" , "2-new" , "2-old" . Keys are unique, but some might be missing. Now using Kotlin and KafkaStreams API I can log those messages with have same key id from new and old. val windows = JoinWindows.of(Duration.of(2, MINUTES).toMillis()) val newStream = stream.filter({ key, _ -> isNew(key) }) .map({key, value -> KeyValue(key.replace(NEW_PREFIX, ""), value) }) val oldStream = stream.filter({ key, _ -> isOld(key) }) .map({key, value -> KeyValue(key.replace(OLD_PREFIX, ""), value) }) val

Linq to Entities and LEFT OUTER JOIN issue with MANY:1 relations

ⅰ亾dé卋堺 提交于 2019-11-30 20:12:24
Can somebody tell me, why does Linq to Entities translate many to 1 relationships to left outer join instead of inner join ? Because there's referential constraint on DB itself that ensures there's a record in the right table, so inner join should be used instead (and it would work much faster) If relation was many to 0..1 left outer join would be correct. Question Is it possible to write LINQ in a way so it will translate to inner join rather than left outer join . It would speed query execution a lot... I haven't used eSQL before, but would it be wise to use it in this case? Would it solve

How to use oracle outer join with a filter where clause

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 15:01:46
问题 If i write a sql: select * from a,b where a.id=b.id(+) and b.val="test" and i want all records from a where corresponding record in b does not exist or it exists with val="test", is this the correct query? 回答1: You're much better off using the ANSI syntax SELECT * FROM a LEFT OUTER JOIN b ON( a.id = b.id and b.val = 'test' ) You can do the same thing using Oracle's syntax as well but it gets a bit hinkey SELECT * FROM a, b WHERE a.id = b.id(+) AND b.val(+) = 'test' Note that in both cases, I

How to use oracle outer join with a filter where clause

别说谁变了你拦得住时间么 提交于 2019-11-30 13:27:22
If i write a sql: select * from a,b where a.id=b.id(+) and b.val="test" and i want all records from a where corresponding record in b does not exist or it exists with val="test", is this the correct query? You're much better off using the ANSI syntax SELECT * FROM a LEFT OUTER JOIN b ON( a.id = b.id and b.val = 'test' ) You can do the same thing using Oracle's syntax as well but it gets a bit hinkey SELECT * FROM a, b WHERE a.id = b.id(+) AND b.val(+) = 'test' Note that in both cases, I'm ignoring the c table since you don't specify a join condition. And I'm assuming that you don't really want

(Lazy) LEFT OUTER JOIN using the Hibernate Criteria API

谁说胖子不能爱 提交于 2019-11-30 12:47:16
问题 I want to perform a LEFT OUTER JOIN between two tables using the Criteria API. All I could find in the Hibernate documentation is this method: Criteria criteria = this.crudService .initializeCriteria(Applicant.class) .setFetchMode("products", FetchMode.JOIN) .createAlias("products", "product"); However, this either performs an inner join or a right outer join, because of the number of results it returns. I also want my join to be Lazy. How can I do this? Cheers! UPDATE: It seems that using