Related
wonder if you could help me out on the below.
I´m using Deneb to visualize small multiples in PBI and I´m not able to find out how to add text labels above/below the bar.
Does anyone know the workaround by chance?
Here´s the code that I´m using so far:
{
"data": {"values": [
{"Region":"A","Month":"1","Difference":"-0.01"},
{"Region":"A","Month":"2","Difference":"0"},
{"Region":"A","Month":"3","Difference":"-0.03"},
{"Region":"A","Month":"4","Difference":"-0.01"},
{"Region":"A","Month":"5","Difference":"-0.01"},
{"Region":"A","Month":"6","Difference":"0.05"},
{"Region":"A","Month":"7","Difference":"-0.05"},
{"Region":"A","Month":"8","Difference":"-0.03"},
{"Region":"A","Month":"9","Difference":"0.03"},
{"Region":"A","Month":"10","Difference":"-0.01"},
{"Region":"A","Month":"11","Difference":"-0.01"},
{"Region":"A","Month":"12","Difference":"0.03"},
{"Region":"B","Month":"1","Difference":"-0.02"},
{"Region":"B","Month":"2","Difference":"-0.02"},
{"Region":"B","Month":"3","Difference":"0.02"},
{"Region":"B","Month":"4","Difference":"0.03"},
{"Region":"B","Month":"5","Difference":"-0.05"},
{"Region":"B","Month":"6","Difference":"-0.02"},
{"Region":"B","Month":"7","Difference":"-0.01"},
{"Region":"B","Month":"8","Difference":"0.03"},
{"Region":"B","Month":"9","Difference":"-0.03"},
{"Region":"B","Month":"10","Difference":"-0.03"},
{"Region":"B","Month":"11","Difference":"0.01"},
{"Region":"B","Month":"12","Difference":"-0.02"},
{"Region":"C","Month":"1","Difference":"-0.05"},
{"Region":"C","Month":"2","Difference":"-0.04"},
{"Region":"C","Month":"3","Difference":"-0.03"},
{"Region":"C","Month":"4","Difference":"0"},
{"Region":"C","Month":"5","Difference":"0"},
{"Region":"C","Month":"6","Difference":"-0.02"},
{"Region":"C","Month":"7","Difference":"-0.05"},
{"Region":"C","Month":"8","Difference":"0.02"},
{"Region":"C","Month":"9","Difference":"0"},
{"Region":"C","Month":"10","Difference":"-0.03"},
{"Region":"C","Month":"11","Difference":"-0.03"},
{"Region":"C","Month":"12","Difference":"0.02"},
{"Region":"D","Month":"1","Difference":"0.05"},
{"Region":"D","Month":"2","Difference":"-0.02"},
{"Region":"D","Month":"3","Difference":"-0.05"},
{"Region":"D","Month":"4","Difference":"-0.05"},
{"Region":"D","Month":"5","Difference":"0"},
{"Region":"D","Month":"6","Difference":"-0.01"},
{"Region":"D","Month":"7","Difference":"0.02"},
{"Region":"D","Month":"8","Difference":"-0.01"},
{"Region":"D","Month":"9","Difference":"0"},
{"Region":"D","Month":"10","Difference":"-0.01"},
{"Region":"D","Month":"11","Difference":"0.01"},
{"Region":"D","Month":"12","Difference":"-0.03"}
]},
"mark": {
"type": "bar",
"stroke": "black",
"opacity": 1,
"cornerRadius": 2,
"tooltip":true
},
"width": 440,
"height": 75,
"cornerRadius": 2,
"encoding": {
"facet": {
"field": "Region",
"type": "ordinal",
"title": null,
"columns": 2
},
"x": {
"field": "Month",
"type": "ordinal",
"axis": {"labelAngle": 0}
},
"y": {
"field": "Difference",
"type": "quantitative",
"axis": {
"format": "0%",
"formatType": "pbiFormat"
}
},
"color": {
"condition": {
"test": "datum['Difference']<0",
"value": "#F78272"
},
"value": "#F2C80F"
},
"text": {
"field": "Difference",
"type": "quantitative"
}
}
}
Many thanks in advance!
*edit1: added desired output
*edit2: added dataset into the code
Desired outcome:
How's this?
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"Region": "A", "Month": "1", "Difference": "-0.01"},
{"Region": "A", "Month": "2", "Difference": "0"},
{"Region": "A", "Month": "3", "Difference": "-0.03"},
{"Region": "A", "Month": "4", "Difference": "-0.01"},
{"Region": "A", "Month": "5", "Difference": "-0.01"},
{"Region": "A", "Month": "6", "Difference": "0.05"},
{"Region": "A", "Month": "7", "Difference": "-0.05"},
{"Region": "A", "Month": "8", "Difference": "-0.03"},
{"Region": "A", "Month": "9", "Difference": "0.03"},
{"Region": "A", "Month": "10", "Difference": "-0.01"},
{"Region": "A", "Month": "11", "Difference": "-0.01"},
{"Region": "A", "Month": "12", "Difference": "0.03"},
{"Region": "B", "Month": "1", "Difference": "-0.02"},
{"Region": "B", "Month": "2", "Difference": "-0.02"},
{"Region": "B", "Month": "3", "Difference": "0.02"},
{"Region": "B", "Month": "4", "Difference": "0.03"},
{"Region": "B", "Month": "5", "Difference": "-0.05"},
{"Region": "B", "Month": "6", "Difference": "-0.02"},
{"Region": "B", "Month": "7", "Difference": "-0.01"},
{"Region": "B", "Month": "8", "Difference": "0.03"},
{"Region": "B", "Month": "9", "Difference": "-0.03"},
{"Region": "B", "Month": "10", "Difference": "-0.03"},
{"Region": "B", "Month": "11", "Difference": "0.01"},
{"Region": "B", "Month": "12", "Difference": "-0.02"},
{"Region": "C", "Month": "1", "Difference": "-0.05"},
{"Region": "C", "Month": "2", "Difference": "-0.04"},
{"Region": "C", "Month": "3", "Difference": "-0.03"},
{"Region": "C", "Month": "4", "Difference": "0"},
{"Region": "C", "Month": "5", "Difference": "0"},
{"Region": "C", "Month": "6", "Difference": "-0.02"},
{"Region": "C", "Month": "7", "Difference": "-0.05"},
{"Region": "C", "Month": "8", "Difference": "0.02"},
{"Region": "C", "Month": "9", "Difference": "0"},
{"Region": "C", "Month": "10", "Difference": "-0.03"},
{"Region": "C", "Month": "11", "Difference": "-0.03"},
{"Region": "C", "Month": "12", "Difference": "0.02"},
{"Region": "D", "Month": "1", "Difference": "0.05"},
{"Region": "D", "Month": "2", "Difference": "-0.02"},
{"Region": "D", "Month": "3", "Difference": "-0.05"},
{"Region": "D", "Month": "4", "Difference": "-0.05"},
{"Region": "D", "Month": "5", "Difference": "0"},
{"Region": "D", "Month": "6", "Difference": "-0.01"},
{"Region": "D", "Month": "7", "Difference": "0.02"},
{"Region": "D", "Month": "8", "Difference": "-0.01"},
{"Region": "D", "Month": "9", "Difference": "0"},
{"Region": "D", "Month": "10", "Difference": "-0.01"},
{"Region": "D", "Month": "11", "Difference": "0.01"},
{"Region": "D", "Month": "12", "Difference": "-0.03"}
]
},
"spec": {
"width": 440,
"height": 75,
"encoding": {
"x": {"field": "Month", "type": "ordinal", "axis": {"labelAngle": 0}},
"y": {
"field": "Difference",
"type": "quantitative",
"axis": {"format": "0%", "formatType": "pbiFormat"}
},
"color": {
"condition": {"test": "datum['Difference']<0", "value": "#F78272"},
"value": "#F2C80F"
}
},
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"opacity": 1,
"cornerRadius": 2,
"tooltip": true
}
},
{
"mark": {
"type": "text",
"dy": {"expr": "datum.Difference < 0 ? 10 : -10"}
},
"encoding": {"text": {"field": "Difference", "type": "quantitative"}}
}
]
},
"facet": {"field": "Region", "type": "ordinal", "title": null},
"columns": 2
}
I want to find all occurrences of freeWifi = "Y" and state = "NY" in the a json string but if there 2 consecutive occurences it consider them as one match instead of 2:
The pattern I used is '"freeWifi": "Y",(\s+\S+)+state": "NY"'.
When I use '"freeWifi": "Y",(\s+\S+){5}state": "NY"' it gives me the desired solution but it is not general enough in case the new lines are added to the json file.
Part of the data:
"freeWifi": "Y",
"storeNumber": "14372",
"phone": "(305)672-7055",
"state": "NY",
"storeUrl": "http://www.mcflorida.com/14372",
"playplace": "N",
"address": "1601 ALTON RD",
"storeType": "FREESTANDING",
"archCard": "Y",
"driveThru": "Y"
}
"type": "Feature",
"properties": {
"city": "MIAMI",
"zip": "33135",
"freeWifi": "Y",
"storeNumber": "7408",
"phone": "(305)285-0974",
"state": "NY",
"storeUrl": "http://www.mcflorida.com/7408",
"playplace": "Y",
"address": "1400 SW 8TH ST",
"storeType": "FREESTANDING",
"archCard": "Y",
"driveThru": "Y"
}
},
{
Part II
After implementing Steven solution, when I tried it on the data file with many entries, the program ran forever and did not give an answer.
The new regex is: '"freeWifi": "Y",(\s+?\S+?)+?state": "NY"'.
To see why the system hangs I checked the program against part of the data, increasing the size by 100,000 bytes each time. The results shows significant slowdown as the size increases' showing possibly problem of the regex, as explained in Program run forever when matching regex.
Sorry for the lousy display of the table, but I could not make it nicer (I removed tabs and padded with spaces but it ignores them)
Time_Passed.....Size_Checked File_Size Matches
7.3e-05 ...........100000 8345167 30
0.008906 200000 8345167 30
0.466485 300000 8345167 31
0.500054 400000 8345167 75
0.523969 500000 8345167 142
0.553361 600000 8345167 201
0.586032 700000 8345167 201
1.072181 800000 8345167 338
1.114541 900000 8345167 482
1.157304 1000000 8345167 630
1.203889 1100000 8345167 630
1.625656 1200000 8345167 630
3.126974 1300000 8345167 630
6.501044 1400000 8345167 630
12.476704 1500000 8345167 630
The lazy operator is ?. Your expression with the lazy operator would be "freeWifi": "Y",(\s+?\S+?)+state": "NY" See example in regexr.
As #anubhava has pointed out, this is not going to work on generic input. For example I imagine that you don't want this match:
"type": "Feature",
"properties": {
"freeWifi": "Y",
"storeNumber": "9876",
"state": "PA"
}
},
"type": "Feature",
"properties": {
"freeWifi": "N",
"storeNumber": "1234",
"state": "NY",
}
},
so, i have 12 list's with Number , and i will compare it, with a Input with Number .I will that each List to compare with the input , and print the number similar with the input .
example:
input : 2 14 34 12 23 45
first list : ["2", "14", "18", "28","40", "48"]
output 2 14
my code:
w = raw_input("give number: ").split()
a1 = ["2", "14", "18", "28","40", "48"]
a2 = ["5", "9", "17", "21", "32", "49"]
a3 = ["4", "18", "19", "30", "47", "49"]
a4 = ["9", "15", "25", "28", "39", "43"]
a5 = ["8", "11", "13", "25", "39", "48"]
a6 = ["3", "12", "13", "14", "31", "33"]
a7 = ["3", "12", "14", "23", "26", "45"]
a8 = ["1", "10", "12", "15", "18", "37"]
a9 = ["6", "7", "17", "38", "41", "44"]
a10 = ["1", "7", "14", "17", "27", "35"]
a11 = ["15", "23", "25", "26", "39", "48"]
a12 = ["5", "12", "14", "30", "41", "48"]
for a,b,c,d,e,f,g,h,i,j,k,l in zip(a1, b2, c3, d4, e5, f6, g7, h8, i9, j10, k11, l12):
if a in w :
print "(1)", a
elif b in w:
print "(2)", b
elif c in w:
print "(3)", c
elif d in w:
print "(4)", d
elif e in w:
print "(5)", e
elif f in w:
print "(6)", f
elif g in w:
print "(7)", g
elif h in w:
print "(8)", h
elif i in w:
print "(9)", i
elif j in w:
print "(10)", j
elif k in w:
print "(11)", k
else:
print "(12)", a
This is what i come....
give number: 2 14 18 28
(1) 2
(1) 14
(1) 18
(1) 28
(8) 40
(12) 48
Can you Please help me.... Thanks!
People help me for this question(not here...)...very thanks them!!, The solution for my problem ... i write the solution maybe another people to need it...
bet_numbers = [
{"2", "14", "18", "28","40", "48"},
{"5", "9", "17", "21", "32", "49"},
{"4", "18", "19", "30", "47", "49"},
{"9", "15", "25", "28", "39", "43"},
{"8", "11", "13", "25", "39", "48"}, #created set Lists with curly braces {}
{"3", "12", "13", "14", "31", "33"},
{"3", "12", "14", "23", "26", "46"},
{"1", "10", "12", "15", "18", "37"},
{"6", "7", "17", "38", "41", "44"},
{"1", "7", "14", "17", "27", "35"},
{"15", "23", "25", "26", "39", "48"},
{"5", "12", "14", "30", "41", "48"},
]
drawn_numbers = set(raw_input("drawn numbers: ").split()) # build a set List
for index, numbers in enumerate(bet_numbers, start=1): #with enumerate(),enumerate each List
correct = drawn_numbers & numbers #with "identifier" add Input + numbers = (1), (2),....
if correct: #if statement without comparison because True is...
print "({}) {}".format(index, ', '.join(sorted(correct)))
#"({}) {}".format() = concatenate elements together .
# (index, ', '.join(sorted(correct))) = (1), (2),...sorted(correct),sorted the set lists output
We are using selenium grid to all UI testcases.
We are facing issue when any variable having value 1 which is getting entered into any text field.
e.g.
set test variable ${data} 1
input text ${data}
if a variable has value set to 1 but below value is getting set:
/tmp/21fe989d-6c5d-413b-8365-cf6da42e92b9/upload957182740231871694file/1
Due to this testcases are failing as text field expectes int but it gets above value.
I am not sure from where "/tmp/21fe989d-6c5d-413b-8365-cf6da42e92b9/upload957182740231871694file/" this part is getting appended to the variable value.
This is strage as it happens only when value is 1.
Below is the detail log from test exection:
16:56:00.882 INFO Typing text '1' into text field 'xpath=//input[#name='floorValue']'
16:56:00.883 DEBUG POST http://192.168.1.201:4444/wd/hub/session/e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e/elements {"using": "xpath", "sessionId": "e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e", "value": "//input[#name='floorValue']"}
16:56:00.905 DEBUG Finished Request
16:56:00.905 DEBUG POST http://192.168.1.201:4444/wd/hub/session/e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e/element/26/clear {"sessionId": "e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e", "id": "26"}
16:56:00.931 DEBUG Finished Request
16:56:00.933 DEBUG POST http://192.168.1.201:4444/wd/hub/session/e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e/file {"sessionId": "e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e", "id": "26", "file": "UEsDBBQAAAAIAGJU9Uhr90YTkgoAAF5CAAABAAAAMe1bbW/bOBL+HP8Kwf5g+dZRGvd6iwtOi3Ob\n9tBDui2SvuCQBAQtMTa7suQVqdTeX398lUhJfpHk7uWA+kMiUjMPh8OZ4QwlDR7SZOkEyXKZxCCj\nOMIUI+JdYUIvIYUOXq6SlDq63asnX6BohVJNnCIY0iTEAZXkaTJLqBfhWQpTTv0ywxF9G2ty1ezl\n3PqK0BTH87wfxmGy1C2KlzldQnKOTX4ZQooEkRBBt5yD747FECGK9KTlLOAKa6oomc9RKm/eoAjF\nOFtOrsQsN5qm3F9P/XpNUUxwEpNtfAVFj/0GDvHLFO6oNyBoUukvODmFk6WR4zv9BaWri7Oz858n\n3vnfvL96538/v5hMJmfT8F8Qx+/mS3r25fH36NNiEX96DOM/vK9k1edDBxEkxHnFlpiiD2kSZgF1\nRxe93kmIHhwAcIwpAC5B0QPrPTkZkIwZhvuSL947GEOmsLG46eW0I0ZG0w2nPhlYwIxmBgkiANw+\nu/dscE79gNlUIVs2n5mAt4J04X1NcOzqBpwR/j9vhzjl5C4AnBOA0Wg8fD/7igJ6jVbJUGBycC+Z\nfU1ZD8MtTNnVoxVkZMJ1qczXHXlzRIG08g2TlVAYB8gdlhfEGIetVwuAYkUFFFoHaEWF+gwvYC1p\nnx6OHxKXdXmMEIjGiLMNThrpWk/Y/zW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Vk2YZCzKgw45aLcU1DRvayatSla5gJ0r1lqYDgWrhfcE69Udauu8q9dU\nqw1tri7l7Zjxdkq2ehVnluD6RUl+rd1Xtmr9VhHuPEN+YYi7JS1qswvu1GjLIqTjitjvVPI77Y+S\nOXfHo2QToutRMsd6ek6/TVWdC7n2O6ZEUlvmjj0TGu5m95V3zYr7yf1wZm2ctiPOao5j//cBq26b\nbO8mp2rNjnC0W4fT6WjXBHx6XrNTc93PQP7vN8v60yHbjW/k00flwLqlXVe3a/fMnLi6azZPVBRW\nnYvpe61rLcXfrdwqgXSsuBRaN58aqFKCU33Xraleg60XovCx+ud7tk2We8vP+HbaaIX5O9tqebx2\nhZPWU/faaQtSl/KpBPkEt4Xd+juC2XZ56le2nkbVj+KtL4AC8XEn0N40E0/pi5PawyW1vhKVD/tN\ndy2NEzK16BcG9aeRW89yd40tl0kNWz5J3WrrZa7iM0nzmYKFte0TowpU8YVRjUeo+cMHilKhErHJ\n9xp4gRa0EGzHOx3aI9SXsoK51xsOhz3Mv8LmH6gCwN+h6wOw5Iygz1ai/jP2j4jQm4x5If8OOURp\n74Twll/ud0fejF+5/dcXd6tsdnrNkaYZTZZiug84htHdNLxB6SNKwRc0u3u/QjG4/vgSFFR3lwhG\nRP4FfAggxvDomvIXRsTQ3oN4ZczFcRBl/I1Cnrn4w+s3/+bqZ+uVRdTxHUmbZrGbZJQpwD+GYHeU\nyeStlxGTprdNZddChC8pG5+py2wdRTmGDN43DgvknInLjS2l/vBogyzoMhqOo2R+HEwGJCFH0hr/\nC1BLAQIUAxQAAAAIAGJU9Uhr90YTkgoAAF5CAAABAAAAAAAAAAAAAACkgQAAAAAxUEsFBgAAAAAB\nAAEALwAAALEKAAAAAA==\n"}
16:56:00.943 DEBUG Finished Request
16:56:00.944 DEBUG POST http://192.168.1.201:4444/wd/hub/session/e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e/element/26/value {"sessionId": "e8d83ee3-7a75-40cd-a079-bb2c83d6fb2e", "id": "26", "value": ["/", "t", "m", "p", "/", "e", "8", "d", "8", "3", "e", "e", "3", "-", "7", "a", "7", "5", "-", "4", "0", "c", "d", "-", "a", "0", "7", "9", "-", "b", "b", "2", "c", "8", "3", "d", "6", "f", "b", "2", "e", "/", "u", "p", "l", "o", "a", "d", "6", "0", "5", "4", "3", "8", "4", "5", "8", "0", "2", "8", "1", "8", "0", "7", "9", "3", "f", "i", "l", "e", "/", "1"]}"
I am trying to sort the below map( Clojure) on the basis of "col_nm" field, but unable to do so.
{:Mawb {:user_val "3", :col_nm "1"},
:HawbDate {:user_val "", :col_nm "3"},
:EtlBatchID {:user_val "1", :col_nm "2"}}
The output should be:
{:Mawb {:user_val "3", :col_nm "1"},
:EtlBatchID {:user_val "1", :col_nm "2"},
:HawbDate {:user_val "", :col_nm "3"} }
Can anyone help me, thanks in advance.
Try this one:
(def m {:Mawb {:user_val "3", :col_nm "1"},
:HawbDate {:user_val "", :col_nm "3"},
:EtlBatchID {:user_val "1", :col_nm "2"}})
(sort-by (comp :col_nm second) m)
=> ([:Mawb {:user_val "3", :col_nm "1"}]
[:EtlBatchID {:user_val "1", :col_nm "2"}]
[:HawbDate {:user_val "", :col_nm "3"}])