multiple-conditions

LINQ Joining in C# with multiple conditions

白昼怎懂夜的黑 提交于 2019-11-27 17:26:27
I have a LINQ Joining statement in C# with multiple conditions. var possibleSegments = from epl in eventPotentialLegs join sd in segmentDurations on new { epl.ITARequestID, epl.ITASliceNumber, epl.DepartAirportAfter, epl.AirportId_Origin, epl.AirportId_Destination } equals new { sd.ITARequestId, sd.SliceIndex, sd.OriginAirport, sd.DestinationAirport } where epl.DepartAirportAfter > sd.UTCDepartureTime and epl.ArriveAirportBy > sd.UTCArrivalTime select new PossibleSegments{ ArrivalTime = sd.arrivalTime }; The joining does not work correctly. What am I doing wrong? AFAIK you can only join this

I use OR to form a multiple condition IF ELSE statement on VBA, it's not working

夙愿已清 提交于 2019-11-27 15:48:39
Dim cat As Integer For cat = 2 To last Range("AB" & cat).Select If Selection.Value = " " Then ActiveCell.Offset(0, -2).Value = "-" ActiveCell.Offset(0, -1).Value = "-" ElseIf Selection.Value = "Address in local wording" Then ActiveCell.Offset(0, -2).Value = "Customer" ActiveCell.Offset(0, -1).Value = "Incomplete information or awaiting more info from customer" ElseIf (Selection.Value = "hold to console" Or "Hold to console" Or "Allocated 14/12 and ship next day") Then ActiveCell.Offset(0, -2).Value = "Depot" ActiveCell.Offset(0, -1).Value = "Allotment delay" ElseIf (Selection.Value =

Multiple conditions in if statement on both sides of the logical operator

无人久伴 提交于 2019-11-27 08:08:04
问题 I was experimenting with having multiple arguments in an if statement on both sides of the logical operator. I first started with the || operator, which worked as expected: var a = 'apple', b = 'banana', c = 'cherry'; if (a == 'banana' || a == 'apple' || b == 'banana' || b == 'apple') { console.log('example 1') // returns } if ((a || b) == 'banana' || (a || b) == 'apple') { console.log('example 2') // returns } if (a == ('apple' || 'banana') || b == ('apple' || 'banana')) { console.log(

How do I create a new column based on multiple conditions from multiple columns?

纵饮孤独 提交于 2019-11-26 21:21:26
问题 I'm trying add a new column to a data frame based on several conditions from other columns. I have the following data: > commute <- c("walk", "bike", "subway", "drive", "ferry", "walk", "bike", "subway", "drive", "ferry", "walk", "bike", "subway", "drive", "ferry") > kids <- c("Yes", "Yes", "No", "No", "Yes", "Yes", "No", "No", "Yes", "Yes", "No", "No", "Yes", "No", "Yes") > distance <- c(1, 12, 5, 25, 7, 2, "", 8, 19, 7, "", 4, 16, 12, 7) > > df = data.frame(commute, kids, distance) > df

I use OR to form a multiple condition IF ELSE statement on VBA, it's not working

若如初见. 提交于 2019-11-26 17:21:16
问题 Dim cat As Integer For cat = 2 To last Range("AB" & cat).Select If Selection.Value = " " Then ActiveCell.Offset(0, -2).Value = "-" ActiveCell.Offset(0, -1).Value = "-" ElseIf Selection.Value = "Address in local wording" Then ActiveCell.Offset(0, -2).Value = "Customer" ActiveCell.Offset(0, -1).Value = "Incomplete information or awaiting more info from customer" ElseIf (Selection.Value = "hold to console" Or "Hold to console" Or "Allocated 14/12 and ship next day") Then ActiveCell.Offset(0, -2)

Filter multiple values on a string column in dplyr

混江龙づ霸主 提交于 2019-11-26 11:40:38
I have a data.frame with character data in one of the columns. I would like to filter multiple options in the data.frame from the same column. Is there an easy way to do this that I'm missing? Example: data.frame name = dat days name 88 Lynn 11 Tom 2 Chris 5 Lisa 22 Kyla 1 Tom 222 Lynn 2 Lynn I'd like to filter out Tom and Lynn for example. When I do: target <- c("Tom", "Lynn") filt <- filter(dat, name == target) I get this error: longer object length is not a multiple of shorter object length You need %in% instead of == : library(dplyr) target <- c("Tom", "Lynn") filter(dat, name %in% target)

What is better ? Multiple if statements, or one if with multiple conditions

南笙酒味 提交于 2019-11-26 06:01:39
问题 For my work I have to develop a small Java application that parses very large XML files (~300k lines) to select very specific data (using Pattern ), so I\'m trying to optimize it a little. I was wondering what was better between these 2 snippets : if(boolean_condition && matcher.find(string)) { ... } OR if(boolean_condition) { if(matcher.find(string)) { ... } } More precisions : These if statements are executed on each iteration inside a loop (~20k iterations) The boolean_condition is a

Filter multiple values on a string column in dplyr

爷,独闯天下 提交于 2019-11-26 03:26:27
问题 I have a data.frame with character data in one of the columns. I would like to filter multiple options in the data.frame from the same column. Is there an easy way to do this that I\'m missing? Example: data.frame name = dat days name 88 Lynn 11 Tom 2 Chris 5 Lisa 22 Kyla 1 Tom 222 Lynn 2 Lynn I\'d like to filter out Tom and Lynn for example. When I do: target <- c(\"Tom\", \"Lynn\") filt <- filter(dat, name == target) I get this error: longer object length is not a multiple of shorter object