The problem seems to be that df_sample["Date"] = ... (i.e. setindex!(df_sample, ..., "Date") gets converted to df_sample.Date = ... (setproperty!(df_sample, :Date, ...)), which is not allowed in Pandas:
function setindex!(o::PyObject, v, s::Union{Symbol, AbstractString})
Base.depwarn("`setindex!(o::PyObject, v, s::Union{Symbol, AbstractString})` is deprecated in favor of `setproperty!(o, s, v)`.", :setindex!)
return _setproperty!(o, s, v)
end
(you can find this by prepending @which in front of the df_sample["Data"] = ... line.)
As a workaround you could use e.g. df_sample = df_sample.assign(Date = ...) In general, I’ll refer to the Pandas documentation for alternative ways to add columns.
By the way, note that PythonCall.jl does not exhibit this issue:
using Pkg
Pkg.add("PythonCall")
ENV["PYTHON"] = "/path/to/your/python/envs/executable"
using PythonCall # after setting the environment variable
pd = pyimport("pandas")
df = pd.read_csv("data.csv")
#=
Python:
A B C
0 1.0 2.0 3.0
1 -1.0 -2.0 -3.0
=#
df["New"] = ["x", "y"]
display(df)
#=
Python:
A B C New
0 1.0 2.0 3.0 x
1 -1.0 -2.0 -3.0 y
=#