Total Pageviews
2019/05/31
2019/05/30
2019/05/29
2019/05/28
2019/05/15
[Google Spreadsheet] How to realize group by function in Google Spreadsheet?
Assume I have the following raw data:
We can make good use of query function to meet group by requirement:
Check the result:
Reference
[1] https://webapps.stackexchange.com/questions/36103/how-to-group-data-in-a-google-spreadsheet
We can make good use of query function to meet group by requirement:
Check the result:
Reference
[1] https://webapps.stackexchange.com/questions/36103/how-to-group-data-in-a-google-spreadsheet
Labels:
GoogleDoc
2019/05/14
[Java 8] An example to remove an element from a Map via Lambda
Example
Console
package com.example.demo; import lombok.extern.slf4j.Slf4j; import java.util.HashMap; import java.util.Map; /** * An example to remove an element from a Map via Lambda */ @Slf4j public class MapTest { private static Map<Integer, String> mapData = new HashMap<>(); private void createDummyData() { mapData.put(1, "Albert"); mapData.put(2, "Mandy"); mapData.put(3, "Eric"); mapData.put(4, "Eason"); mapData.put(5, "Mia"); mapData.put(6, "Leon"); } public void doTest() { createDummyData(); log.debug("mapData = {}", mapData); } public static void main(String[] args) { new MapTest().doTest(); // remove by key mapData.keySet().removeIf(key -> key == 1); log.debug("[remove key = 1] mapData = {}", mapData); // remove by value mapData.values().removeIf(value -> "Eric".equals(value)); log.debug("[remove value = \"Eric\"] mapData = {}", mapData); } }
Console
/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=49591:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/tools.jar:/Users/guojunyou/IdeaProjects/demo/target/classes:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.0.6.RELEASE/spring-boot-starter-actuator-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-starter/2.0.6.RELEASE/spring-boot-starter-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.0.6.RELEASE/spring-boot-starter-logging-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/guojunyou/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/guojunyou/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar:/Users/guojunyou/.m2/repository/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar:/Users/guojunyou/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/Users/guojunyou/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/guojunyou/.m2/repository/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.0.6.RELEASE/spring-boot-actuator-autoconfigure-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-actuator/2.0.6.RELEASE/spring-boot-actuator-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.7/jackson-databind-2.9.7.jar:/Users/guojunyou/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/guojunyou/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.7/jackson-core-2.9.7.jar:/Users/guojunyou/.m2/repository/org/springframework/spring-context/5.0.10.RELEASE/spring-context-5.0.10.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/spring-aop/5.0.10.RELEASE/spring-aop-5.0.10.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/spring-beans/5.0.10.RELEASE/spring-beans-5.0.10.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/spring-expression/5.0.10.RELEASE/spring-expression-5.0.10.RELEASE.jar:/Users/guojunyou/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.7/jackson-datatype-jsr310-2.9.7.jar:/Users/guojunyou/.m2/repository/io/micrometer/micrometer-core/1.0.7/micrometer-core-1.0.7.jar:/Users/guojunyou/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.10/HdrHistogram-2.1.10.jar:/Users/guojunyou/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-devtools/2.0.6.RELEASE/spring-boot-devtools-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot/2.0.6.RELEASE/spring-boot-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.0.6.RELEASE/spring-boot-autoconfigure-2.0.6.RELEASE.jar:/Users/guojunyou/.m2/repository/org/projectlombok/lombok/1.16.22/lombok-1.16.22.jar:/Users/guojunyou/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/guojunyou/.m2/repository/org/springframework/spring-core/5.0.10.RELEASE/spring-core-5.0.10.RELEASE.jar:/Users/guojunyou/.m2/repository/org/springframework/spring-jcl/5.0.10.RELEASE/spring-jcl-5.0.10.RELEASE.jar com.example.demo.MapTest 20:45:22.257 [main] DEBUG com.example.demo.MapTest - mapData = {1=Albert, 2=Mandy, 3=Eric, 4=Eason, 5=Mia, 6=Leon} 20:45:22.327 [main] DEBUG com.example.demo.MapTest - [remove key = 1] mapData = {2=Mandy, 3=Eric, 4=Eason, 5=Mia, 6=Leon} 20:45:22.328 [main] DEBUG com.example.demo.MapTest - [remove value = "Eric"] mapData = {2=Mandy, 4=Eason, 5=Mia, 6=Leon} Process finished with exit code 0
2019/05/13
[GoogleDoc] Using max function in conditional formatting
Problem
Assume I have a number of row, I would like to highlight the max value. How to do it?
How-To
Steps are:
1. Select the range of data => Format => Conditional formatting...
2. Configure conditional formatting rules
3. Check result
Reference
[1] https://webapps.stackexchange.com/questions/100381/using-max-in-conditional-formatting-only-evaluates-numbers-after-the-cell-regar
Assume I have a number of row, I would like to highlight the max value. How to do it?
How-To
Steps are:
1. Select the range of data => Format => Conditional formatting...
2. Configure conditional formatting rules
3. Check result
Reference
[1] https://webapps.stackexchange.com/questions/100381/using-max-in-conditional-formatting-only-evaluates-numbers-after-the-cell-regar
Labels:
GoogleDoc
2019/05/12
2019/05/11
[Java] How to get the count of line in file?
Here has a simple example to demonstrate how to get the count of lines in file:
package com.example.demo; import lombok.experimental.UtilityClass; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @UtilityClass public class FileUtils { public static Long getLines(String filePath) throws IOException { Path path = Paths.get(filePath); Long count = Files.lines(path).count(); return count; } }
Labels:
Java
2019/05/10
若前期為負數,該如何計算成長率
當沒有負數時,常用的公式如下,但若出現負數時,卻會出現負數的成長率:
網路上有看到的參考公式 (分母加上絕對值),讓成長率轉正:
兩種方式都有一些問題:第一個公式無法正確反映成長的結果;然而,第二個公式出現如此高的成長率,但是無法告訴你,會有如此高的成長率是因為前期是負數的關係。
所以,最好的做法應該是給個備註,說明前期是負數的關係故不予顯示,或是顯示公式二的值,再加上備註說明,會是比較好的說明方式。
網路上有看到的參考公式 (分母加上絕對值),讓成長率轉正:
兩種方式都有一些問題:第一個公式無法正確反映成長的結果;然而,第二個公式出現如此高的成長率,但是無法告訴你,會有如此高的成長率是因為前期是負數的關係。
所以,最好的做法應該是給個備註,說明前期是負數的關係故不予顯示,或是顯示公式二的值,再加上備註說明,會是比較好的說明方式。
Subscribe to:
Posts (Atom)