C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# comparing length of node values

By : Prabas
Date : November 28 2020, 01:01 AM
will be helpful for those in need The length function as it stands is meant to be used with collections. There is currently no way to get a length of a string in cypher. I've started work on adding a bunch of new string functions like soundex and charindex, and I'll throw this one on the stack of things to do, but I probably won't get it finished for a couple more weeks (and it needs to go through acceptance and even then will only be available as M05+, probably).
code :

Share :

## Matlab: Comparing two vectors with different length and different values?

By : Mr.xiong
Date : March 29 2020, 07:55 AM
help you fix your problem It sounds like what you are trying to do is have an ismember function for use on real valued data.
That is, check for each value B(i) in your vector B whether B(i) is within the tolerance threshold T of at least one value in your vector A
code :
``````tf = false(1, length(b)); %//the result vector, true if that element of b is in a
t = 0.01; %// the tolerance threshold
for i = 1:length(b)
%// is the absolute difference between the
%//element of a and b less that the threshold?
matches = abs(a - b(i)) < t;

%// if b(i) matches any of the elements of a
tf(i) = any(matches);
end
``````
``````t = 0.01;
tf = arrayfun(@(bi) any(abs(a - bi) < t), b);
``````

## Comparing node values and writing the value of another node based on that comparison with XSLT

By : harish
Date : March 29 2020, 07:55 AM
The transform I have written so far is just not right and apparently oversimplified.
code :
``````<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:key name="part" match="strow" use="stentry[@props='part-number']" />

<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="stentry[@props='part-name']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:variable name="matching-part" select="key('part', ../stentry[@props='part-number'], document('otherfile.xml'))" />
<xsl:choose>
<xsl:when test="\$matching-part">
<xsl:value-of select="\$matching-part/stentry[@props='part-name']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
``````

## Comparing the values in the same position of two equal length data.frames in R

By : Cluchi97
Date : March 29 2020, 07:55 AM
seems to work fine This is what tapply() is designed for. Here's a demo using randomized data (so the lat/lon positions and state names won't correspond to reality):
code :
``````states <- c('Bayern','Saarland','BadenW','SAnhalt','Sachsen','MVorpommern','NRWestfalen','Berlin','Hamburg','Bremen','SHolstein','Niedersachsen','Hessen','Thueringen','RPfalz','Brandenburg');
lats <- seq(51.30,by=-0.05,len=281);
lons <- seq(8.70,by=0.05,len=321);
set.seed(1);
Laender <- as.data.frame(matrix(sample(states,length(lats)*length(lons),replace=T),length(lats),dimnames=list(sprintf('%.2f',lats),sprintf('%.2f',lons))));
df <- as.data.frame(matrix(pmax(0,round(rnorm(length(lats)*length(lons),5,20))),length(lats),dimnames=list(sprintf('%.2f',lats),sprintf('%.2f',lons))));
Laender[1:6,1:6];
##              8.70        8.75          8.80          8.85        8.90     8.95
## 51.30     Sachsen     Hamburg   MVorpommern        Berlin      Hessen   Hessen
## 51.25 MVorpommern      RPfalz Niedersachsen        Berlin      RPfalz   Berlin
## 51.20      Bremen MVorpommern        RPfalz   NRWestfalen     Sachsen   Bayern
## 51.15      RPfalz      Bayern Niedersachsen        Bayern      Berlin   BadenW
## 51.05      RPfalz MVorpommern     SHolstein Niedersachsen MVorpommern Saarland
df[1:6,1:6];
##       8.70 8.75 8.80 8.85 8.90 8.95
## 51.30   16    1    0   14    0    5
## 51.25   24    0   11    0   27    0
## 51.20   15    0    0   13    0   25
## 51.15    0   21    0   21    2    0
## 51.10   30    0    0   15    0    0
## 51.05    0    0    0   31    0    0
tapply(as.matrix(df),as.matrix(Laender),mean);
##        BadenW        Bayern        Berlin   Brandenburg        Bremen
##      10.35327      10.30455      10.80498      11.09401      10.57423
##       Hamburg        Hessen   MVorpommern Niedersachsen   NRWestfalen
##      11.05088      10.55788      10.66969      10.90239      11.09304
##        RPfalz      Saarland       Sachsen       SAnhalt     SHolstein
##      10.54924      10.48975      10.87170      10.49251      10.51719
##    Thueringen
##      10.52608
``````
``````Laender <- as.matrix(read.csv('path/file.csv',row.names=1,check.names=F));
``````
``````mean(df[Laender=='BadenW']);
## [1] 10.35327
``````
``````sapply(unique(c(as.matrix(Laender))),function(s) mean(df[Laender==s]));
##       Sachsen   MVorpommern        Bremen        RPfalz       SAnhalt
##      10.87170      10.66969      10.57423      10.54924      10.49251
##   Brandenburg     SHolstein        Bayern        BadenW   NRWestfalen
##      11.09401      10.51719      10.30455      10.35327      11.09304
##        Hessen        Berlin Niedersachsen    Thueringen      Saarland
##      10.55788      10.80498      10.90239      10.52608      10.48975
##       Hamburg
##      11.05088
``````

## copy values from one dataframe to another dataframe(different length) by comparing row values in python

By : Hải Nguyên Trần
Date : March 29 2020, 07:55 AM
hop of those help? As @Merlin has already mentioned joining (using pd.merge() method) should be pretty straightforward:
code :
``````In [126]: pd.merge(daily.drop('Val', 1), monthly.drop('Date', 1), on=['Year','Month'])
Out[126]:
Date  Year  Month  val   Val
0   2016-01-01  2016      1    0  0.00
1   2016-01-02  2016      1    0  0.00
2   2016-01-03  2016      1    0  0.00
3   2016-01-04  2016      1    0  0.00
4   2016-01-05  2016      1    0  0.00
5   2016-01-06  2016      1    0  0.00
6   2016-01-07  2016      1    0  0.00
7   2016-01-08  2016      1    0  0.00
8   2016-01-09  2016      1    0  0.00
9   2016-01-10  2016      1    0  0.00
10  2016-01-11  2016      1    0  0.00
11  2016-01-12  2016      1    0  0.00
12  2016-01-13  2016      1    0  0.00
13  2016-01-14  2016      1    0  0.00
14  2016-01-15  2016      1    0  0.00
..         ...   ...    ...  ...   ...
137 2016-05-17  2016      5    0  0.28
138 2016-05-18  2016      5    0  0.28
139 2016-05-19  2016      5    0  0.28
140 2016-05-20  2016      5    0  0.28
141 2016-05-21  2016      5    0  0.28
142 2016-05-22  2016      5    0  0.28
143 2016-05-23  2016      5    0  0.28
144 2016-05-24  2016      5    0  0.28
145 2016-05-25  2016      5    0  0.28
146 2016-05-26  2016      5    0  0.28
147 2016-05-27  2016      5    0  0.28
148 2016-05-28  2016      5    0  0.28
149 2016-05-29  2016      5    0  0.28
150 2016-05-30  2016      5    0  0.28
151 2016-05-31  2016      5    0  0.28

[152 rows x 5 columns]
``````
``````In [108]: df
Out[108]:
Val       Date  Year  Month
0  0.00 2016-01-31  2016      1
1  0.10 2016-02-28  2016      2
2  0.07 2016-03-31  2016      3
3  0.01 2016-04-30  2016      4
4  0.28 2016-05-31  2016      5

Out[117]:
Date   Val  Year  Month
0   2016-01-01  0.00  2016      1
1   2016-01-02  0.00  2016      1
2   2016-01-03  0.00  2016      1
3   2016-01-04  0.00  2016      1
4   2016-01-05  0.00  2016      1
5   2016-01-06  0.00  2016      1
6   2016-01-07  0.00  2016      1
7   2016-01-08  0.00  2016      1
8   2016-01-09  0.00  2016      1
9   2016-01-10  0.00  2016      1
10  2016-01-11  0.00  2016      1
11  2016-01-12  0.00  2016      1
12  2016-01-13  0.00  2016      1
13  2016-01-14  0.00  2016      1
14  2016-01-15  0.00  2016      1
..         ...   ...   ...    ...
137 2016-05-17  0.28  2016      5
138 2016-05-18  0.28  2016      5
139 2016-05-19  0.28  2016      5
140 2016-05-20  0.28  2016      5
141 2016-05-21  0.28  2016      5
142 2016-05-22  0.28  2016      5
143 2016-05-23  0.28  2016      5
144 2016-05-24  0.28  2016      5
145 2016-05-25  0.28  2016      5
146 2016-05-26  0.28  2016      5
147 2016-05-27  0.28  2016      5
148 2016-05-28  0.28  2016      5
149 2016-05-29  0.28  2016      5
150 2016-05-30  0.28  2016      5
151 2016-05-31  0.28  2016      5

[152 rows x 4 columns]
``````
``````In [112]: df.set_index('Date').resample('MS').mean()
Out[112]:
Val  Year  Month
Date
2016-01-01  0.00  2016      1
2016-02-01  0.10  2016      2
2016-03-01  0.07  2016      3
2016-04-01  0.01  2016      4
2016-05-01  0.28  2016      5
``````
``````In [113]: df.set_index('Date').resample('MS').mean().append(x.iloc[[-1]])
Out[113]:
Val  Year  Month
Date
2016-01-01  0.00  2016      1
2016-02-01  0.10  2016      2
2016-03-01  0.07  2016      3
2016-04-01  0.01  2016      4
2016-05-01  0.28  2016      5
2016-05-31  0.28  2016      5
``````

## XSLT Filter comparing two values in same sub node

By : Joe Delaney
Date : March 29 2020, 07:55 AM
help you fix your problem To remove Film elements where FilmPostDate and FilmActiveDate you can actually nest the conditions in the match attribute
code :
``````<xsl:template
match="m:Film[m:FilmPostings/m:FilmPosting/m:FilmPostingDates[m:FilmPostDate = m:FilmActiveDate]]" />
``````
``````<xsl:template
match="m:Film[not(m:FilmPostings/m:FilmPosting/m:FilmPostingDates[m:FilmPostDate != m:FilmActiveDate])]" />
``````