Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add spanish translation, Literate.jl backend #30

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a200be1
add literate jl files
miguelraz Apr 18, 2021
53433ec
traslation to spanish README
miguelraz Apr 18, 2021
88f18ed
translation to spanish 02
miguelraz Apr 18, 2021
cf1fcf7
translation to spanish 02_basicinfo.jl
miguelraz Apr 18, 2021
9b82f62
translation to spanish 03_missingvalues.jl
miguelraz Apr 18, 2021
51662a6
translation to spanish 04_loadsave.jl
miguelraz Apr 18, 2021
80375c0
translation to spanish 05_columns.jl
miguelraz Apr 18, 2021
9769314
spanish translation of 06_rows.jl
miguelraz Apr 18, 2021
3bb8157
spanish translation of 07_factors.jl
miguelraz Apr 18, 2021
b4a9c49
spanish translation of 08_joins.jl
miguelraz Apr 18, 2021
f461dd0
spanish translation of 09_reshaping.jl
miguelraz Apr 18, 2021
73a8f67
spanish translation of 10_transforms.jl
miguelraz Apr 18, 2021
49ea34a
update topics in README.md
miguelraz Apr 18, 2021
670e441
spanish translation of 11_performance.jl
miguelraz Apr 18, 2021
2f0ff63
spanish translation of 12_pitfalls.jl
miguelraz Apr 18, 2021
669663c
spanish translation of 13_extras.jl
miguelraz Apr 18, 2021
fb6a33c
Update literate_notebooks/src-ES/01_constructors.jl
miguelraz Apr 18, 2021
e2a8f25
Update literate_notebooks/src-ES/01_constructors.jl
miguelraz Apr 18, 2021
c862b3b
Update literate_notebooks/src-ES/01_constructors.jl
miguelraz Apr 18, 2021
8a31c93
Update literate_notebooks/src-ES/01_constructors.jl
miguelraz Apr 18, 2021
b88e172
spanish translation - add cheatsheets and language comparisons docs
miguelraz Apr 18, 2021
ed6c52c
Merge branch 'spanish-tutorials' of https://github.com/miguelraz/Juli…
miguelraz Apr 18, 2021
c0dd3c4
spanish translation - missed intro in 03_missingvalues.jl
miguelraz Apr 18, 2021
96a326b
spanish translation - add .toml files, fixup typos and word choices
miguelraz Apr 18, 2021
9edb30d
update stale 01_constructors.jl
miguelraz Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 46 additions & 42 deletions literate_notebooks/src-ES/13_extras.jl
Original file line number Diff line number Diff line change
@@ -1,175 +1,179 @@
# # Introduction to DataFrames
# # Introducción a DataFrames
# **[Bogumił Kamiński](http://bogumilkaminski.pl/about/), May 13, 2018**
# (Traducción de Miguel Raz Guzmán Macedo, 18 de Abril de 2021)

using DataFrames

# ## Extras - selected functionalities of selected packages
# ## Extras - funcionalidades especiales de paqueterías selectas

#-

# ### FreqTables: creating cross tabulations
# ### FreqTables: crear tabulaciones cruzadas

using FreqTables
df = DataFrame(a=rand('a':'d', 1000), b=rand(["x", "y", "z"], 1000))
ft = freqtable(df, :a, :b) # observe that dimensions are sorted if possible
ft = freqtable(df, :a, :b) # nota: las dimensiones se ordenan si es posible

#-

ft[1,1], ft['b', "z"] # you can index the result using numbers or names
ft[1,1], ft['b', "z"] # puedes indexar el resultado con números o nombres

#-

prop(ft, 1) # getting proportions - 1 means we want to calculate them in rows (first dimension)
prop(ft, 1) # obtener tamaños - 1 significa que lo queremos calcular en filas (primera dimensión)


#-

prop(ft, 2) # and columns are normalized to 1.0 now
prop(ft, 2) # y las columnas se normalizan a 1.0

#-

x = categorical(rand(1:3, 10))
levels!(x, [3, 1, 2, 4]) # reordering levels and adding an extra level
freqtable(x) # order is preserved and not-used level is shown
levels!(x, [3, 1, 2, 4]) # reorganizar niveles y añadir un nivel extra
freqtable(x) # el orden se manteine y los nivelos no usados se meustran
miguelraz marked this conversation as resolved.
Show resolved Hide resolved

#-

freqtable([1,1,2,3,missing]) # by default missings are listed
freqtable([1,1,2,3,missing]) # por default los valores faltatnes (`missing`s) se muestran en lista
miguelraz marked this conversation as resolved.
Show resolved Hide resolved

#-

freqtable([1,1,2,3,missing], skipmissing=true) # but we can skip them
freqtable([1,1,2,3,missing], skipmissing=true) # pero nos los podemos saltar

# ### DataFramesMeta - working on `DataFrame`
# ### DataFramesMeta - trabajando en un `DataFrame`

using DataFramesMeta
df = DataFrame(x=1:8, y='a':'h', z=repeat([true,false], outer=4))

#-

@with(df, :x+:z) # expressions with columns of DataFrame
@with(df, :x+:z) # expresiones con columnas de DataFrame

#-

@with df begin # you can define code blocks
@with df begin # puedes definir bloques de código
a = :x[:z]
b = :x[.!:z]
:y + [a; b]
end

#-

a # @with creates hard scope so variables do not leak out
a # `@with` crea un `hard scope` (alcance léxico fuerte) y así las variables no se derraman al ambiente

#-

df2 = DataFrame(a = [:a, :b, :c])
@with(df2, :a .== ^(:a)) # sometimes we want to work on raw Symbol, ^() escapes it
@with(df2, :a .== ^(:a)) # A veces queremos un `Symbol` a secas, usamos ^() para escapar esa secuencia

#-

df2 = DataFrame(x=1:3, y=4:6, z=7:9)
@with(df2, _I_(2:3)) # _I_(expression) is translated to df2[expression]
@with(df2, _I_(2:3)) # `_I_(expresión)` se traduce a `df2[expression]`

#-

@where(df, :x .< 4, :z .== true) # very useful macro for filtering
@where(df, :x .< 4, :z .== true) # macro muy útil para filtrar

#-

@select(df, :x, y = 2*:x, z=:y) # create a new DataFrame based on the old one
@select(df, :x, y = 2*:x, z=:y) # crea un nuevo DataFrame basado en el anterior

#-

@transform(df, a=1, x = 2*:x, y=:x) # create a new DataFrame adding columns based on the old one
@transform(df, a=1, x = 2*:x, y=:x) # crea un DataFrame agregando columnas basado en el anterior

#-

@transform(df, a=1, b=:a) # old DataFrame is used and :a is not present there
@transform(df, a=1, b=:a) # se usa el DataFrame anterior y `:a` no está presente ahí

#-

@orderby(df, :z, -:x) # sorting into a new data frame, less powerful than sort, but lightweight
@orderby(df, :z, -:x) # ordenando los datos en un nuevo DataFrame, menos poderoso que `sort` pero mucho más ligero

#-

@linq df |> # chaining of operations on DataFrame
@linq df |> # podemos encadenar operaciones sobre un DataFrame
where(:x .< 5) |>
orderby(:z) |>
transform(x²=:x.^2) |>
select(:z, :x, :x²)

#-

f(df, col) = df[col] # you can define your own functions and put them in the chain
f(df, col) = df[col] # puees definir tus propias funcioens y ponerlas en una cadena (`chain` = cadena, como las de metal)
miguelraz marked this conversation as resolved.
Show resolved Hide resolved
@linq df |> where(:x .<= 4) |> f(:x)

# ### DataFramesMeta - working on grouped `DataFrame`
# ### DataFramesMeta - trabajando con `DataFrame` agrupado

df = DataFrame(a = 1:12, b = repeat('a':'d', outer=3))
g = groupby(df, :b)

#-

@by(df, :b, first=first(:a), last=last(:a), mean=mean(:a)) # more convinient than by from DataFrames
@by(df, :b, first=first(:a), last=last(:a), mean=mean(:a)) # más conveniente que `by` de `DataFrames.jl`

#-

@based_on(g, first=first(:a), last=last(:a), mean=mean(:a)) # the same as by but on grouped DataFrame
@based_on(g, first=first(:a), last=last(:a), mean=mean(:a)) #lo mismo que `by` pero en un DataFrame agrupado

#-

@where(g, mean(:a) > 6.5) # filter gropus on aggregate conditions
@where(g, mean(:a) > 6.5) # filtramos grupos con condiciones agregadas

#-

@orderby(g, -sum(:a)) # order groups on aggregate conditions
@orderby(g, -sum(:a)) # ordenar grupos con condiciones agregadas

#-

@transform(g, center = mean(:a), centered = :a - mean(:a)) # perform operations within a group and return ungroped DataFrame
@transform(g, center = mean(:a), centered = :a - mean(:a)) # aplicar operaciones dentro de un grupo y regresar un DataFrame no agrupado

#-

DataFrame(g) # a nice convinience function not defined in DataFrames
DataFrame(g) # una función auxiliar bonita no definida en DataFrames.jl

#-

@transform(g) # actually this is the same
@transform(g) # de hecho esto es lo mismo

#-

@linq df |> groupby(:b) |> where(mean(:a) > 6.5) |> DataFrame # you can do chaining on grouped DataFrames as well
@linq df |> groupby(:b) |> where(mean(:a) > 6.5) |> DataFrame # puedes encadenar operaciones sobre DataFrames agrupado también

# ### DataFramesMeta - rowwise operations on `DataFrame`
# ### DataFramesMeta - operaciones por filas en un `DataFrame`

df = DataFrame(a = 1:12, b = repeat(1:4, outer=3))

#-

## such conditions are often needed but are complex to write
## dichas condiciones suelen ser necesarios pero son demasiado complejas para escribirlas
miguelraz marked this conversation as resolved.
Show resolved Hide resolved
@transform(df, x = ifelse.((:a .> 6) .& (:b .== 4), "yes", "no"))

#-

## one option is to use a function that works on a single observation and broadcast it
## una opciön es usar una función que se aplica sobre una sola observación y la broadcasteamos
# Broadcasting en el manual: https://docs.julialang.org/en/v1/manual/arrays/#Broadcasting
myfun(a, b) = a > 6 && b == 4 ? "yes" : "no"
@transform(df, x = myfun.(:a, :b))

#-

## or you can use @byrow! macro that allows you to process DataFrame rowwise
## o puedes usar el macro `@byrow` que permite procesar el DataFrame por filas
@byrow! df begin
@newcol x::Vector{String}
:x = :a > 6 && :b == 4 ? "yes" : "no"
end

# ### Visualizing data with StatPlots
# ### Visualizando datos con StatPlots

using StatPlots # you might need to setup Plots package and some plotting backend first
using StatPlots # Puede ser necesario instalar algunos paquetes de Plots.jl y el backend antes de proseguir

#-

## we present only a minimal functionality of the package
## presentamos la funcionalidad mínima de este paquete, no nos da para cubrir todo lo que ofrece

#-

Expand All @@ -178,15 +182,15 @@ df = DataFrame(x = sort(randn(1000)), y=randn(1000), z = [fill("b", 500); fill("

#-

@df df plot(:x, :y, legend=:topleft, label="y(x)") # a most basic plot
@df df plot(:x, :y, legend=:topleft, label="y(x)") # la gráfica más básica

#-

@df df density(:x, label="") # density plot
@df df density(:x, label="") # gráfica de densidad

#-

@df df histogram(:y, label="y") # and a histogram
@df df histogram(:y, label="y") # un histograma

#-

Expand Down