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

Reading from file to NamedArray #109

Open
Mastomaki opened this issue May 11, 2021 · 4 comments
Open

Reading from file to NamedArray #109

Mastomaki opened this issue May 11, 2021 · 4 comments

Comments

@Mastomaki
Copy link

Documentation should be added about the best ways to read from text file to NamedArray. My current plan is to first read a DataFrame via CSV.jl and then convert it using the function provided by dietercastel.

@Mastomaki
Copy link
Author

For missing values I edit the original function of dietercastel as follows:

function convert(t::Type{NamedArray}, df::DataFrame; valueCol = :Values)
   newdimnames = propertynames(df)
   deleteat!(newdimnames,findfirst(x->x==valueCol,newdimnames))
   names = map(dn->unique(df[!,dn]),newdimnames)
   lengths = map(length,names)

    newna = NamedArray( Array{Union{Missing, Float64}}(missing, lengths...), tuple(names...), tuple(newdimnames...))
    for row in eachrow(df)
        a = [row[col] for col in newdimnames]
        newna[a...] = row[valueCol]
    end
   return newna
end

However, the datatype of the named array should be set according to the original dataframe.

@davidavdav
Copy link
Owner

Yes, documentation. I have to study how that works. Do you know of a recommended and hosted platform for that?

@Mastomaki
Copy link
Author

Not really. I believe the documentation of registered packages appears in https://juliapackages.com/ if it is present in the Github repository. And documenter.jl can be used to make documentation.

@sciencepeak
Copy link

sciencepeak commented Aug 12, 2021

Yes, documentation. I have to study how that works. Do you know of a recommended and hosted platform for that?

I think it is not necessary to master documenter.jl to write a formal, perfect documentation. If the usage of conversion between NamedArray and DataFrame can be added to the ReadMe file of this repository, that is good enough for now for people to learn it.

I think your package is very important for Julia to attract data science users from Python Pandas and R, where data frame and matrix can be easily converted to each other and transposed without losing row names or column names. Thanks a lot for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants