Delete duplicate lines from string vb.net - vb.net

Is there a way to remove all duplicate lines from a string. For example i have a string
Mystring = "INSERT INTO Table(Column1, Column2) Values(50, 50), (100, 100), (50, 50)"
How to delete second (50, 50)

Related

Get (index,column) pair where the value is True

Say I have a dataframe df
a b c
0 False True True
1 False False False
2 True True False
3 False False False
I would like all (index,column) pairs e.g (0,"b"),(0,"c),(2,"a"),(2,"b") where the True value is.
Is there a way to do that, without looping over either the index or columns?
Assuming booleans in the input, you can use:
df.where(df).stack().index.to_list()
output:
[(0, 'b'), (0, 'c'), (2, 'a'), (2, 'b')]
Let us try np.where:
r, c = np.where(df)
[*zip(df.index[r], df.columns[c])]
[(0, 'b'), (0, 'c'), (2, 'a'), (2, 'b')]
df1.stack().to_frame('col1').query('col1').index.tolist()

Is there any way to mapping point between 2 ecliptic curve?

The ecliptic curve E1: y^2 = x^3+7 over F17 with the base point G is (15, 13)
and the second ecliptic curve E2: y^2 = x^3+7 over F31 with the same base point G is (15, 13).
My question is: is there any way to calculate the equivalent point of F31 based on F17?
For example: with 7G = (10, 15) of curve F17, how to calculate 7G of F31 ? The result should be 7G = (12, 14) on F31.
Below is all points of two curves:
#----Curve F17-------#
1G = (15, 13)
2G = (2, 10)
3G = (8, 3)
4G = (12, 1)
5G = (6, 6)
6G = (5, 8)
7G = (10, 15)
8G = (1, 12)
9G = (3, 0)
10G = (1, 5)
11G = (10, 2)
12G = (5, 9)
13G = (6, 11)
14G = (12, 16)
15G = (8, 14)
16G = (2, 7)
17G = (15, 4)
#----Curve F31-------#
1G = (15, 13)
2G = (29, 17)
3G = (1, 22)
4G = (20, 19)
5G = (21, 17)
6G = (23, 23)
7G = (12, 14)
8G = (11, 27)
9G = (25, 22)
10G = (7, 19)
11G = (27, 27)
12G = (5, 9)
13G = (0, 24)
14G = (4, 12)
15G = (22, 23)
16G = (3, 13)
17G = (13, 18)
18G = (17, 23)
19G = (24, 4)
20G = (24, 27)
21G = (17, 8)
22G = (13, 13)
23G = (3, 18)
24G = (22, 8)
25G = (4, 19)
26G = (0, 7)
27G = (5, 22)
28G = (27, 4)
29G = (7, 12)
30G = (25, 9)
31G = (11, 4)

look through array assign values into cells

I have 2d-array like this below. There are 26 values from 1-26, but also "bigger" categories, e.g. 2nd value: "Important", "very important", "extremely important", and are all classified as "check".
Can I integrate this into this Array like adding after "important: priority (1,3)? Or (2,3) Sorry, I am starting with Arrays.... I do not fully understand this yet. The values I then want to populate into columns. Example, if column = 1 then column2 = "Important" and column3 = "check" and so on.
Dim Priority(1 To 26, 1 To 2)
Priority(1, 1) = 1: Priority(1, 2) = "Important"
For Each Zelle In Range(Cells(FirstRow + 2, 14), Cells(LastRow, 14))
Zelle.Offset(0, 1) = Application.VLookup(Zelle, Priority, 3, False)
Zelle.Value = Application.VLookup(Zelle, Priority, 2, False)
'Zelle = IIf(IsError(Zelle), "???", "Zelle")
Next Zelle
it checks CellX and then goes directly to CellX+1 and so on...I am sure this could be also done with For i Loop

Using multiple SQL insert statements in one command to insert multiple rows to a table using a windows form in Visual Basic,

i am seeking for a set of code which would allow me to insert 8 rows of data at once in to a table in a SQL database table.
something like this,
sqlur = objCon.CreateCommand()
strSQL = "INSERT INTO RESULTS (CandidateNumber,CandidateName,VotesReceived) VALUES ('" & candNo1 & "', '" & votefname1 & "','" & votesgot1 & "');"
'strSQL = "INSERT INTO RESULTS (CandidateNumber,CandidateName,VotesReceived) VALUES ('" & candNo2 & "', '" & votefname2 & "','" & votesgot2 & "');"
thank you !
Typically I avoid using the Values function and go with a SELECT statement if the values come from another table.
INSERT INTO RESULTS (CandidateNumber, CandidateName, VotesReceived)
SELECT candNo, votefname, votesgot
FROM ResultsTable
You can use a SQL like this:
INSERT INTO RESULTS (CandidateNumber, CandidateName, VotesReceived) VALUES (
1, 'NAME 1', 100,
2, 'NAME 2', 150,
3, 'NAME 1', 57,
4, 'NAME 4', 100,
5, 'NAME 5', 28,
6, 'NAME 6', 57,
7, 'NAME 7', 38,
8, 'NAME 8', 294
)

Data handling for matplotlib histogram with error bars

I've got a data set which is a list of tuples in python like this:
dataSet = [(6.1248199999999997, 27), (6.4400500000000003, 4), (5.9150600000000004, 1), (5.5388400000000004, 38), (5.82559, 1), (7.6892199999999997, 2), (6.9047799999999997, 1), (6.3516300000000001, 76), (6.5168699999999999, 1), (7.4382099999999998, 1), (5.4493299999999998, 1), (5.6254099999999996, 1), (6.3227700000000002, 1), (5.3321899999999998, 11), (6.7402300000000004, 4), (7.6701499999999996, 1), (5.4589400000000001, 3), (6.3089700000000004, 1), (6.5926099999999996, 2), (6.0003000000000002, 5), (5.9845800000000002, 1), (6.4967499999999996, 2), (6.51227, 6), (7.0302600000000002, 1), (5.7271200000000002, 49), (7.5311300000000001, 7), (5.9495800000000001, 2), (5.1487299999999996, 18), (5.7637099999999997, 6), (5.5144500000000001, 44), (6.7988499999999998, 1), (5.2578399999999998, 1)]
Where the first element of the tuple is an energy and the second a counter, how many sensor where affected.
I want to create a histogram to study the relation between the number of affected sensors and the energy. I'm pretty new to matplotlib (and python), but this is what I've done so far:
import math
import matplotlib.pyplot as plt
dataSet = [(6.1248199999999997, 27), (6.4400500000000003, 4), (5.9150600000000004, 1), (5.5388400000000004, 38), (5.82559, 1), (7.6892199999999997, 2), (6.9047799999999997, 1), (6.3516300000000001, 76), (6.5168699999999999, 1), (7.4382099999999998, 1), (5.4493299999999998, 1), (5.6254099999999996, 1), (6.3227700000000002, 1), (5.3321899999999998, 11), (6.7402300000000004, 4), (7.6701499999999996, 1), (5.4589400000000001, 3), (6.3089700000000004, 1), (6.5926099999999996, 2), (6.0003000000000002, 5), (5.9845800000000002, 1), (6.4967499999999996, 2), (6.51227, 6), (7.0302600000000002, 1), (5.7271200000000002, 49), (7.5311300000000001, 7), (5.9495800000000001, 2), (5.1487299999999996, 18), (5.7637099999999997, 6), (5.5144500000000001, 44), (6.7988499999999998, 1), (5.2578399999999998, 1)]
binWidth = .2
binnedDataSet = []
#create another list and append the "binning-value"
for item in dataSet:
binnedDataSet.append((item[0], item[1], math.floor(item[0]/binWidth)*binWidth))
energies, sensorHits, binnedEnergy = [[q[i] for q in binnedDataSet] for i in (0,1,2)]
plt.plot(binnedEnergy, sensorHits, 'ro')
plt.show()
This works so far (although it doesn't even look like a histogram ;-) but OK), but now I want to calculate the mean value for each bin and append some error bars.
What's the way to do it? I looked at histogram examples for matplotlib, but they all use one-dimensional data which will be counted, so you get a frequency spectrum… That's not really what I want.
I am somewhat confused by exactly what you are trying to do, but I think this (to first order) will do what I think you want:
bin_width = .2
bottom = 5.0
top = 8.0
binned_data = [0.0] * int(math.ceil(((top - bottom) / bin_width)))
binned_count = [0] * int(math.ceil(((top - bottom) / bin_width)))
n_bins = len(binned_data)
for E, cnt in dataSet:
if E < bottom or E > top:
print 'out of range'
continue
bin_id = int(math.floor(n_bins * (E - bottom) / (top - bottom)))
binned_data[bin_id] += cnt
binned_count[bin_id] += 1
binned_avergaed_data = [C_sum / hits if hits > 0 else 0 for C_sum, hits in zip(binned_data, binned_count)]
bin_edges = [bottom + j * bin_width for j in range(len(binned_data))]
plt.bar(bin_edges, binned_avergaed_data, width=bin_width)
I would also suggest looking into numpy, it would make this much simpler to write.