diff --git a/docs/src/man/basics.md b/docs/src/man/basics.md index b0809569cb..475eb9eae6 100644 --- a/docs/src/man/basics.md +++ b/docs/src/man/basics.md @@ -474,6 +474,10 @@ Let us start with the example of using the `empty` and `empty!` functions: ```jldoctest dataframe julia> empty(german) 0×10 DataFrame + Row │ id Age Sex Job Housing Saving accounts Checking accoun ⋯ + │ Int64 Int64 String7 Int64 String7 String15 String15 ⋯ +─────┴────────────────────────────────────────────────────────────────────────── + 4 columns omitted julia> german 1000×10 DataFrame @@ -500,9 +504,17 @@ julia> german julia> empty!(german) 0×10 DataFrame + Row │ id Age Sex Job Housing Saving accounts Checking accoun ⋯ + │ Int64 Int64 String7 Int64 String7 String15 String15 ⋯ +─────┴────────────────────────────────────────────────────────────────────────── + 4 columns omitted julia> german 0×10 DataFrame + Row │ id Age Sex Job Housing Saving accounts Checking accoun ⋯ + │ Int64 Int64 String7 Int64 String7 String15 String15 ⋯ +─────┴────────────────────────────────────────────────────────────────────────── + 4 columns omitted ``` In the above example `empty` function created a new `DataFrame` with the same @@ -510,10 +522,11 @@ column names and column element types as `german` but with zero rows. On the other hand `empty!` function removed all rows from `german` in-place and made each of its columns empty. -The difference between the behavior of the `empty` and `empty!` functions is an application of the +The difference between the behavior of the `empty` and `empty!` functions is an +application of the [stylistic convention](https://docs.julialang.org/en/v1/manual/variables/#Stylistic-Conventions) -employed in the Julia language. -This convention is followed in all functions provided by the DataFrames.jl package. +employed in the Julia language. This convention is followed in all functions +provided by the DataFrames.jl package. ### Getting Basic Information about a Data Frame diff --git a/docs/src/man/getting_started.md b/docs/src/man/getting_started.md index 1ab1e95bd4..1638812b02 100644 --- a/docs/src/man/getting_started.md +++ b/docs/src/man/getting_started.md @@ -299,6 +299,9 @@ integers and the second one can only contain strings): ```jldoctest dataframe julia> df = DataFrame(A=Int[], B=String[]) 0×2 DataFrame + Row │ A B + │ Int64 String +─────┴─────────────── ``` Rows can then be added as tuples or vectors, where the order of elements matches that of columns. diff --git a/src/dataframe/dataframe.jl b/src/dataframe/dataframe.jl index 12036fe954..7aa2faa131 100755 --- a/src/dataframe/dataframe.jl +++ b/src/dataframe/dataframe.jl @@ -1014,6 +1014,9 @@ julia> df = DataFrame(a=1:3, b=4:6) julia> empty!(df) 0×2 DataFrame + Row │ a b + │ Int64 Int64 +─────┴────────────── julia> df.a, df.b (Int64[], Int64[]) diff --git a/test/io.jl b/test/io.jl index 31bae4f0fa..ed5ebf0320 100644 --- a/test/io.jl +++ b/test/io.jl @@ -629,137 +629,69 @@ end show(IOContext(io, :limit => true), MIME"text/html"(), DataFrame(a = Int64.(1:26 |> collect))) str = String(take!(io)) - @test str == "
" * - "
" * - "26×1 DataFrame" * - "
" * - "
" * - "1 row omitted" * - "
" * - "
" * - "
" * - "
" * - "
" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "" * - "
Rowa
" * - "Int64
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1515
1616
1717
1818
1919
2020
2121
2222
2323
2424
2525
2626
" * - "
" + @test str == """
26×1 DataFrame
""" * + """
""" * + """
""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """""" * + """
Rowa
Int64
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1414
1515
1616
1717
1818
1919
2020
2121
2222
2323
2424
2525
2626
""" # Test invalid keywords when printing to HTML. @test_throws ArgumentError show(stdout, MIME("text/html"), df, rowid=10)