What is the difference between:
using CSV;
df = CSV.read("data.csv");
and
df = CSV.read("data.csv") |> DataFrame;
I mean, in the first case df is read as DataFrame, what the need for the pipe in the second case?
What is the difference between:
using CSV;
df = CSV.read("data.csv");
and
df = CSV.read("data.csv") |> DataFrame;
I mean, in the first case df is read as DataFrame, what the need for the pipe in the second case?
df = CSV.read("data.csv");
is currently a shorthand for:
df = CSV.read("data.csv", DataFrame);
(in the future the former will be disallowed most likely)
I am not sure where you have seen:
df = CSV.read("data.csv") |> DataFrame;
as this is not needed. You create an unnecessary additional copy of your data frame.
Probably you meant:
df = CSV.File("data.csv") |> DataFrame;
which is a low-level API of CSV.jl.
In short. It is recommended to use:
df = CSV.read("data.csv", DataFrame);
It's just for explicitness. CSV.read("data.csv") |> DataFrame is identical to DataFrame(CSV.read("data.csv")), which in principle guarantees that you'll end up with a DataFrame even if CSV changes their output format at some point in the future.
Note that it would be more ideomatic to write CSV.File("data.csv") |> DataFrame, and this makes it easy to change the output format at any time in the future.