Powershell Get-TransportRule read full data of a transport rule property - powershell

Get-TransportRule "Gmail Block" | Select-Object "ExceptIfFrom" | Format-List
returns the results
ExceptIfFrom : {terer.nolt#gmail.com, calendar-notification#google.com, brianqfaanur#gmail.com, cced1rley657#gmail.com...}
How would I request the entire list?

Update $formatenumerationlimit to a value equal to or larger than your collection size:
# -1 is unlimited
$formatenumerationlimit = -1
When an object's property value is a collection and you are using a view that displays the property/value pair, $formatenumerationlimit automatic variable determines how many items in the collection are visible before being truncated. The default value is 4.
You can easily replicate this situation with a simple object:
$obj = [pscustomobject]#{property = 1,2,3,4,5,6,7,8,9}
$obj
Output:
property
--------
{1, 2, 3, 4...}
Now update $formatenumerationlimit
$formatenumerationlimit = 9
$obj
$formatenumerationlimit = -1
$obj
Output:
property
--------
{1, 2, 3, 4, 5, 6, 7, 8, 9}
property
--------
{1, 2, 3, 4, 5, 6, 7, 8, 9}
Alternatively, retrieving only the property's value will likely display all list items and is not impacted by $formatenumerationlimit.
$obj.property
$obj | Select-Object -ExpandProperty property
Output:
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9

Related

how splitBetween method works

List integerList=[1,2,4,11,14,15,16,16,19,30,31,50,51,100,101,105]; //input
var subList=integerList.splitBetween((v1, v2) => (v2 - v1).abs() > 6);
print(subList); //([1, 2, 4], [11, 14, 15, 16, 16, 19], [30, 31], [50, 51], [100, 101, 105])
what is the logic splitBetween methods works here ?
check each pair of adjacent elements v1 and v2
lets use your data:
[1,2,4,11,14,15,16,16,19,30,31,50,51,100,101,105]
begin with index 0 and 1
we have : v1 = 1 , v2 = 2
then test with the function (v2 - v1).abs() > 6)
( 1-2).abs()>6 = false
index 1 and 2 : v1=2 , v2=4
(2 -4).abs() > 6 = false
index 2 and 3 : v1=4 , v2=11
(4 - 11).abs() > 6 absolute(-7) > 6 = true,
since its true : the elements since the previous chunk-splitting elements are emitted as a list
which means, index 1 - 3 emmited as a list.
current sublist = ([1,2,4])
and so on
index : 4 - 8 is false. and pair of index 8 and 9 is true
current sublist = ([1,2,4], [11,14,15,16,16,19])
repeat untin last index.
lastly :if at last index are false then we keep add to the list. because it says that : Any final elements are emitted at the end.
final result : ([1, 2, 4], [11, 14, 15, 16, 16, 19], [30, 31], [50, 51], [100, 101, 105])

Minizinc : var array with variable size

I want solve this problem : i have a number n and i want to have an array with all pair
(i,j) for all i,j in [1,n]
I write this for solve the problem:
include "globals.mzn";
int:n=2;
var 1..:ArrayLenght;
array[1..ArrayLenght,1..2] of var 1..n:X;
constraint forall(i,j in 1..n)(exists(r in 1..ArrayLenght) (X[r,..] == [i,j]));
solve minimize ArrayLenght;
but i have a type error type error: type-inst must be par set but is 'var set of int' on this line array[1..ArrayLenght,1..2] of var 1..size:X
So how i can do to have an array with a variabe size ? (i don't see anything about this in the official documentation)
NB : for this specific example, it would be better to set the arrayLenght to n*n but it's a minimal example, I have to add constraints that make the size of array cannot be fixed.
MiniZinc does not support variable length arrays. The dimensions of all arrays must be known at compile time. One common approach to handle this is to create a multi-dimensional array of dimension - say - n x m (where n and m are the largest possible values in each dimension) - and then set 0 (or some other value) as a dummy variable for the "invalid" cells.
However, it seems that what you want here is just to create an array of pairs of numbers. It's quite easy to create this without using any decision variables (i.e. without var ...).
Here are two different approaches to generate the pairs:
pairs1 is the pairs with i < j
pairs2 is the all possible pairs
The loop variablek in the list comprehensions is used as a counter to select either the i value or the j in the appropriate places.
int: n = 5;
int: num_pairs1 = n*(n-1) div 2;
int: num_pairs2 = n*n;
array[1..num_pairs1,1..2] of int: pairs1 = array2d(1..num_pairs1,1..2, [ if k == 1 then i else j endif | i,j in 1..n, k in 1..2 where i < j]);
array[1..num_pairs2,1..2] of int: pairs2 = array2d(1..num_pairs2,1..2, [ if k == 1 then i else j endif | i,j in 1..n, k in 1..2]);
output ["pairs1:\n", show2d(pairs1)];
output ["\n\npairs2:\n", show2d(pairs2)];
The output is
pairs1:
[| 1, 2
| 1, 3
| 1, 4
| 1, 5
| 2, 3
| 2, 4
| 2, 5
| 3, 4
| 3, 5
| 4, 5
|]
pairs2:
[| 1, 1
| 1, 2
| 1, 3
| 1, 4
| 1, 5
| 2, 1
| 2, 2
| 2, 3
| 2, 4
| 2, 5
| 3, 1
| 3, 2
| 3, 3
| 3, 4
| 3, 5
| 4, 1
| 4, 2
| 4, 3
| 4, 4
| 4, 5
| 5, 1
| 5, 2
| 5, 3
| 5, 4
| 5, 5
|]
----------
==========
Hope this helps. If not, please describe in more detail what you are looking for.

Python pandas: how to unpack the statsmodel results and create a column in group by dataframe

I am trying to run linear regressions by group and add the results to a new column in the dataframe.
Here is what I'm trying to do.
df2 = pd.DataFrame.from_dict({'case': ['foo', 'foo', 'foo', 'bar', 'bar'],
'cluster': [1, 1, 1, 1, 1],
'conf': [1, 2, 3, 1, 4],
'conf_1': [11, 12, 13, 11, 14]})
def ols_res(df, xcols, ycol):
results = sm.OLS(df[ycol], sm.add_constant(df[xcols])).fit()
return results.get_influence().cooks_distance[0]
df3 = df2.groupby(['case', 'cluster'])
df3.apply(ols_res, xcols='conf', ycol='conf_1')
output I got is :
case cluster
bar 1 [nan, nan]
foo 1 [0.42857142857143005, 0.09642857142857146, 10....
dtype: object
The size of results for each group is same as number of rows in the group.
I need the above output in following format. Can some one please help me?
case cluster conf conf_1 result
0 foo 1 1 11 0.42857142857143005
1 foo 1 2 12 0.09642857142857146
2 foo 1 3 13 10....
4 bar 1 1 11 nan
5 bar 1 4 14 nan
following worked for me.
def ols_res_mod(df, xcols, ycol):
results = sm.OLS(df[ycol], sm.add_constant(df[xcols])).fit()
results.get_influence().cooks_distance[0]
print(df)
df['distance'] = results.get_influence().cooks_distance[0]
return df
not sure, whether this is an efficient way or not.

How to compare 2 sets of different date which contains 2 different sets of data?

I have 2 sets of Date, their 1st and last dates are the same respectively but their dates within might not be the same to each other. Both DateA and DateB contain different values on their each date, which are arrays A and B.
DateA= '2016-01-01'
'2016-01-02'
'2016-01-04'
'2016-01-05'
'2016-01-06'
'2016-01-07'
'2016-01-08'
'2016-01-09'
'2016-01-10'
'2016-01-12'
'2016-01-13'
'2016-01-14'
'2016-01-16'
'2016-01-17'
'2016-01-18'
'2016-01-19'
'2016-01-20'
DateB= '2016-01-01'
'2016-01-02'
'2016-01-03'
'2016-01-04'
'2016-01-05'
'2016-01-09'
'2016-01-10'
'2016-01-11'
'2016-01-12'
'2016-01-13'
'2016-01-15'
'2016-01-16'
'2016-01-17'
'2016-01-19'
'2016-01-20'
A = [5, 2, 3, 4, 6, 1, 7, 9, 3, 6, 1, 7, 9, 2, 1, 4, 6]
B = [4, 2, 7, 1, 8, 4, 9, 5, 3, 9, 3, 6, 7, 2, 9]
I have converted the dates into datenumber,ie
datenumberA= 736330
736331
736333
736334
736335
736336
736337
736338
736339
736341
736342
736343
736345
736346
736347
datenumberB= 736330
736331
736332
736333
736334
736338
736339
736340
736341
736342
736344
736345
736346
736348
736349
Now I want to compare the value of A on DateA(n) to that of B on DateB while DateB is the date that is closest to and before the date of DateA(n).
For example,
comparing the value of A on DateA '2016-01-12' to that of B on DateB '2016-01-11'.
Please help and thanks a lot.
It'll get you the desired output!
all_k=0;
out(1)=1; % not comparing the first index as you mentioned
for n=2:size(datenumberA,1)
j=0;
while 1
k=find(datenumberB+j==datenumberA(n)-1); %finding the index of DateB closest to and before DateA(n)
if size(k,1)==1 break; end %if found, come out of the while loop
j=j+1; % otherwise keep adding 1 in the values of datenumberB until found
end
if size(find(all_k==k),2) ~=1 % to avoid if any DateB is already compared
out(end+1)=A(n)> B(k); %Comparing Value in A with corresponding value in B
all_k(end+1)=k; end %Storing which indices of DateB are already compared
end
out' %Output
Output:-
ans =
1
0
0
1
0
0
1
0
0
1
0
0
1

I need to eliminate alternate rows of an array

I need to eliminate alternate rows of an array, like i have an array of 23847X1 and i need the odd rows and finally making it into 11924X1. It is in .mat file and i want the resultant in the .mat file as well.
Try yourMatrix(1:2:size(yourMatrix, 2)).
The 1:2:N selects all elements from 1 to N with step 2.
A more complete example:
> M=[1, 2, 3, 4, 5, 6, 7]
M =
1 2 3 4 5 6 7
> OddM = M(1:2:size(M, 2))
OddM =
1 3 5 7
To load / store data in data.mat, follow H.Muster's advice below:
load('data.mat'); x = x(1:2:end,:); save('data.mat', 'x')