Comments (3)
I couldn't figure out how to merge but keep open issue #198, so I'll repeat my comments from there:
Also ddresses issues #180.
I thought this was better as a pull request because it hits a few different things that may need feedback. Here are a few items of note:
vecbind
is added. I hoped to usevcat
, but it wasn't good enough (see JuliaLang/julia#2326).- To get NAtype DataArrays to work, I added a promote_rule.
promote_rule{T}(::Type{T}, ::Type{NAtype} ) = T
- Because of this promote_rule, we now get warnings (see below). What is the promote_rule for AbstractDataArrays used for? I don't see something equivalent for AbstractArrays.
Here are some examples:
julia> using DataFrames
Warning: ignoring conflicting import of Stats.quantile into DataFrames
Warning: New definition promote_rule(Type{AbstractDataArray{T,N}},Type{T}) is ambiguous with promote_rule(Type{T},Type{NAtype}) at /home/tshort/.julia/DataFrames/src/natype.jl:32.
Make sure promote_rule(Type{AbstractDataArray{T,N}},Type{NAtype}) is defined first.
Warning: New definition promote_rule(Type{AbstractDataArray{S,N}},Type{T}) is ambiguous with promote_rule(Type{T},Type{NAtype}) at /home/tshort/.julia/DataFrames/src/natype.jl:32.
Make sure promote_rule(Type{AbstractDataArray{S,N}},Type{NAtype}) is defined first.
julia> d1 = @DataFrame(x => NA, y => 1)
1x2 DataFrame:
x y
[1,] NA 1
julia> rbind(d1,d1)
2x2 DataFrame:
x y
[1,] NA 1
[2,] NA 1
julia> d1 = DataFrame({[1:3], LETTERS[1:3]}) # arrays
3x2 DataFrame:
x1 x2
[1,] 1 "A"
[2,] 2 "B"
[3,] 3 "C"
julia> d2 = @DataFrame(x1 => [5:6], y1 => letters[5:6])
2x2 DataFrame:
x1 y1
[1,] 5 "e"
[2,] 6 "f"
julia> rbind(d1,d1)
6x2 DataFrame:
x1 x2
[1,] 1 "A"
[2,] 2 "B"
[3,] 3 "C"
[4,] 1 "A"
[5,] 2 "B"
[6,] 3 "C"
julia> rbind(d1,d2)
5x3 DataFrame:
x1 x2 y1
[1,] 1 "A" NA
[2,] 2 "B" NA
[3,] 3 "C" NA
[4,] 5 NA "e"
[5,] 6 NA "f"
julia> rbind(d2,d1)
5x3 DataFrame:
x1 y1 x2
[1,] 5 "e" NA
[2,] 6 "f" NA
[3,] 1 NA "A"
[4,] 2 NA "B"
[5,] 3 NA "C"
julia> rbind(d2[[2]],d1)
5x3 DataFrame:
y1 x1 x2
[1,] "e" NA NA
[2,] "f" NA NA
[3,] NA 1 "A"
[4,] NA 2 "B"
[5,] NA 3 "C"
julia> rbind(stack_df(d1, ["x1","x2"]),d2)
8x4 DataFrame:
variable value x1 y1
[1,] "x1" 1 NA NA
[2,] "x1" 2 NA NA
[3,] "x1" 3 NA NA
[4,] "x2" "A" NA NA
[5,] "x2" "B" NA NA
[6,] "x2" "C" NA NA
[7,] NA NA 5 "e"
[8,] NA NA 6 "f"
julia> rbind(stack_df(d1, ["x1","x2"]),d2) | dump
DataFrame 8 observations of 4 variables
variable: DataArray{Union(ASCIIString,UTF8String),1}(8) ["x1", "x1", "x1", "x2"]
value: DataArray{Any,1}(8) {1, 2, 3, "A"}
x1: DataArray{Int64,1}(8) [NA, NA, NA, NA]
y1: DataArray{ASCIIString,1}(8) [NA, NA, NA, NA]
from dataframes.jl.
Sorry: I just meant merge, then reopen.
from dataframes.jl.
Long done.
from dataframes.jl.
Related Issues (20)
- `describe` is slow HOT 3
- CartesianIndex error in Julia 1.11 HOT 4
- `DataFrame(x=Int[], y=Int)` HOT 3
- Add comparison function for dataframes which can handle both isapprox and isequal column types HOT 2
- unique fails with column-type FixedDecimal HOT 5
- mapcols! should modify the parent of a SubDataFrame HOT 11
- Feature request: Pairs in stack HOT 2
- Grouped DataFrame with array elements fails to combine HOT 4
- error when combining a grouped empty dataframe using `first` HOT 6
- Short circuit && on subset? HOT 1
- Integer strings as colnames/selectors are error prone HOT 2
- Suggestion - Matrix Syntax for hcat (as well as vcat) HOT 4
- Document custom generation of column names in manual HOT 9
- `join` should not introduce `Missing` types to schema HOT 1
- Consider removing Tables.allocatecolumn in vcat
- DataFrame(t::Table) converts PooledVector columns HOT 2
- Sampling GroupedDataFrames (rand) HOT 5
- Julia 1.12.0-DEV: testing DataFrames throws a 'method dispatch ambiguities' error HOT 2
- Add options to `join` missing error? HOT 1
- Column types seem to change after inner-join between two DataFrames HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dataframes.jl.