Comments (6)
and return a
NamedTuple
.
The design is to:
- return a
NamedTuple
if you do not want pseudo broadcasting; - return a
DataFrame
if you want it.
Example:
julia> df = DataFrame(id=repeat([1, 2], 5), val=1:10)
10×2 DataFrame
Row │ id val
│ Int64 Int64
─────┼──────────────
1 │ 1 1
2 │ 2 2
3 │ 1 3
4 │ 2 4
5 │ 1 5
6 │ 2 6
7 │ 1 7
8 │ 2 8
9 │ 1 9
10 │ 2 10
julia> combine(groupby(df, :id), :val => (x -> (s=sum(x); DataFrame(total=s, frac=x ./ s))) => AsTable)
10×3 DataFrame
Row │ id total frac
│ Int64 Int64 Float64
─────┼─────────────────────────
1 │ 1 25 0.04
2 │ 1 25 0.12
3 │ 1 25 0.2
4 │ 1 25 0.28
5 │ 1 25 0.36
6 │ 2 30 0.0666667
7 │ 2 30 0.133333
8 │ 2 30 0.2
9 │ 2 30 0.266667
10 │ 2 30 0.333333
The question is how to reflect this in DataFramesMeta.jl.
from dataframes.jl.
Hmmm... I don't love the performance hit that would come with constructing a DataFrame
. With the current implementation of the @astable
macro-flag I would have to decide whether a DataFrame
or a NamedTuple
.
I wonder if it's best for DataFramesMeta.jl to do the broadcasting on their own.
However your response is a bit confusing
return a NamedTuple if you do not want pseudo broadcasting;
since currently returning (a = 1, b = [4, 5, 6])
throws an error. So it's not a broadcasting behavior you can opt in-or-out of.
from dataframes.jl.
throws an error.
Yes, because NamedTuple
does not do broadcasting (as opposed to DataFrame
)
from dataframes.jl.
Also I think that the performance hit, although noticeable, for most users would be a minor issue. The major issue, is, as you write, that @astable
has to have only one meaning. Maybe @asdf
or @asdataframe
would be an alternative name?
from dataframes.jl.
Are there other advantages of making a DataFrame
inside fun
?
I don't really want to have to introduce both @astable
and @asdataframe
into the docs and tutorials if the only difference is the spreading behavior. I would just as soon do some spreading inside the anonymous function instead.
from dataframes.jl.
Are there other advantages of making a
DataFrame
inside fun?
I do not think so. The other would be making column names unique, but I guess it is not an issue in your case.
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.