Característica | Streaming de Dados | Processamento em Lotes |
---|---|---|
Tempo de resposta | Milissegundos a segundos | Minutos a horas |
Volume de dados | Contínuo e infinito | Acumulado em intervalos |
Complexidade | Maior | Menor |
Casos de uso | Detecção de fraudes, monitoramento de IoT, redes sociais | Relatórios financeiros, análise histórica |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Criando um vetor de números | |
valores <- c(12, 15, 14, 10, 18, 20, 25, 22) | |
# Calculando estatísticas básicas | |
media <- mean(valores) | |
mediana <- median(valores) | |
desvio_padrao <- sd(valores) | |
# Exibindo os resultados | |
cat("Média:", media, "\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Criando um conjunto de dados | |
dados <- data.frame( | |
x = rnorm(100), | |
y = rnorm(100) | |
) | |
# Criando o gráfico de dispersão | |
ggplot(dados, aes(x=x, y=y)) + | |
geom_point(color="blue") + | |
theme_minimal() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Carregando a biblioteca ggplot2 | |
library(ggplot2) | |
# Criando um DataFrame de exemplo | |
dados <- data.frame( | |
Categoria = c("A", "B", "C"), | |
Valor = c(10, 20, 15) | |
) | |
# Criando o gráfico |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Criando um DataFrame | |
dados <- data.frame( | |
Nome = c("Ana", "Bruno", "Carlos"), | |
Idade = c(25, 30, 22), | |
Salario = c(3000, 4500, 2800) | |
) | |
# Exibindo os dados | |
print(dados) |
numero | par_ou_impar |
---|---|
1 | Ímpar |
2 | Par |
3 | Ímpar |
4 | Par |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Função para verificar se um número é par ou ímpar | |
def even_or_odd(num): | |
return "Par" if num % 2 == 0 else "Írmpar" | |
# Registrando a UDF no Spark | |
even_odd_udf = udf(even_or_odd, StringType()) | |
# Criando DataFrame de exemplo | |
data = [(1,), (2,), (3,), (4,)] | |
df = spark.createDataFrame(data, ["numero"]) |
valor | valor_dobrado |
---|---|
1 | 2 |
2 | 4 |
3 | 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql.types import IntegerType | |
# Função para dobrar o valor | |
def double_value(x): | |
return x * 2 if x is not None else None | |
# Registrando a UDF no Spark | |
double_udf = udf(double_value, IntegerType()) | |
# Criando DataFrame de exemplo |
nome | nome_maiusculo |
---|---|
joao | JOAO |
maria | MARIA |
carlos | CARLOS |