using awk to get column values and then running another command on values and printing them
Tag : unix , By : PatrickSimonHenk
Date : March 29 2020, 07:55 AM
I wish this help you You don't really need awk just for extracting the second column. You can do by using bash read built in and setting the IFS to the delimiter. while IFS=, read -ra line; do
[[ ${line[1]} != 0 ]] && echo "${line[1]}" | openssl dgst -sha1
done < inputFile
|
Categorising values in one column and printing them in a new column in R
Tag : r , By : user121350
Date : March 29 2020, 07:55 AM
around this issue I'm trying to categorize values in a column (Value) based on how it compares to other columns (in this case ColA, ColB, ColC) The category of the value should be written in the corresponding row under the column 'Category'. , importing your data: df <- read.table(text = "
Value ColA ColB ColC
0.8 0.3 0.7 1.1
0.1 0.2 0.7 1.3
0.7 0.5 0.8 1.0", header = T)
df$Category <-
ifelse(df$Value >= 0 & df$Value <= df$ColA, "Bottom",
ifelse(df$Value > df$ColA & df$Value <= df$ColB, "Middle",
ifelse(df$Value > df$ColB & df$Value <= df$ColC, "Top", NA)
)
)
> df
Value ColA ColB ColC Category
1 0.8 0.3 0.7 1.1 Top
2 0.1 0.2 0.7 1.3 Bottom
3 0.7 0.5 0.8 1.0 Middle
ifelse(test, yes, no)
df$Category <- NA
df$Category[df$Value >= 0 & df$Value <= df$ColA] <- "Bottom"
df$Category[df$Value > df$ColA & df$Value <= df$ColB] <- "Middle"
df$Category[df$Value > df$ColB & df$Value <= df$ColC] <- "Top"
> df
Value ColA ColB ColC Category
1 0.8 0.3 0.7 1.1 Top
2 0.1 0.2 0.7 1.3 Bottom
3 0.7 0.5 0.8 1.0 Middle
|
How to group and printing unique values of Column-B wrt to Column-A in pandas?
Date : March 29 2020, 07:55 AM
|
I stored values in Multi Dimensional Array. When printing the values, it's printing the second iteration values and firs
Date : March 29 2020, 07:55 AM
|
Apache Spark in Scala not printing rdd values
Date : March 29 2020, 07:55 AM
|