Skip to content
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
33 changes: 18 additions & 15 deletions literate_notebooks/src-ES/10_transforms.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# # Introduction to DataFrames
# # Introducción a DataFrames
# **[Bogumił Kamiński](http://bogumilkaminski.pl/about/), Apr 21, 2018**
# (Traducción por Miguel Raz Guzmán Macedo, 18 de abril de 2021)

using DataFrames # load package
using DataFrames # cargar paquetería

# ## Split-apply-combine
# ## "Split-apply-combine" - Dividir, aplicar, combinar

x = DataFrame(id=[1,2,3,4,1,2,3,4], id2=[1,2,1,2,1,2,1,2], v=rand(8))

Expand All @@ -17,64 +19,65 @@ gx2 = groupby(x, [:id, :id2])

#-

vcat(gx2...) # back to the original DataFrame
vcat(gx2...) # de regreso al DataFrame original

#-

x = DataFrame(id = [missing, 5, 1, 3, missing], x = 1:5)

#-

showall(groupby(x, :id)) # by default groups include mising values and are not sorted
showall(groupby(x, :id)) # por default los grupos incluyen valores faltantes (`missing`) y no están ordenados

#-

showall(groupby(x, :id, sort=true, skipmissing=true)) # but we can change it :)
showall(groupby(x, :id, sort=true, skipmissing=true)) # pero se puede cambiar :)

#-

x = DataFrame(id=rand('a':'d', 100), v=rand(100));
by(x, :id, y->mean(y[:v])) # apply a function to each group of a data frame
by(x, :id, y->mean(y[:v])) # aplica una función a cada grupo de un DataFrame

#-

by(x, :id, y->mean(y[:v]), sort=true) # we can sort the output
by(x, :id, y->mean(y[:v]), sort=true) # podemos ordenar el output

#-

by(x, :id, y->DataFrame(res=mean(y[:v]))) # this way we can set a name for a column - DataFramesMeta @by is better
by(x, :id, y->DataFrame(res=mean(y[:v]))) # de esta manera podemos fijar el nombre de una columna - `DataFramesMeta @by` es mejor

#-

x = DataFrame(id=rand('a':'d', 100), x1=rand(100), x2=rand(100))
aggregate(x, :id, sum) # apply a function over all columns of a data frame in groups given by id
aggregate(x, :id, sum) # aplica la función sobre todas las columnas de un DataFarme en grupos dados por `:id`

#-

aggregate(x, :id, sum, sort=true) # also can be sorted
aggregate(x, :id, sum, sort=true) # también se puede ordenar

# *We omit the discussion of of map/combine as I do not find them very useful (better to use by)*
# *Omitimos la discusión de `map/combine/` pues no las encuentre tan útiles - mejor usar `by`*

x = DataFrame(rand(3, 5))

#-

map(mean, eachcol(x)) # map a function over each column and return a data frame
map(mean, eachcol(x)) # mapea una función a cada columna y regresa un DataFrame

#-

foreach(c -> println(c[1], ": ", mean(c[2])), eachcol(x)) # a raw iteration returns a tuple with column name and values
foreach(c -> println(c[1], ": ", mean(c[2])), eachcol(x)) # una iteración a secas regresa una tupla con nombres columnares y valores

#-

colwise(mean, x) # colwise is similar, but produces a vector
colwise(mean, x) # `colwise` es similar, pero produce un vector

#-

x[:id] = [1,1,2]
colwise(mean,groupby(x, :id)) # and works on GroupedDataFrame
colwise(mean,groupby(x, :id)) # y funciona en un `GroupedDataFrame`

#-

map(r -> r[:x1]/r[:x2], eachrow(x)) # now the returned value is DataFrameRow which works similarly to a one-row DataFrame
map(r -> r[:x1]/r[:x2], eachrow(x)) # ahora el valor regresado es un `DataFrameRow` el cual funciona similar a un `DataFrame` de una sola fila