Giter Site home page Giter Site logo

Comments (10)

mcrumiller avatar mcrumiller commented on August 18, 2024 1

@ritchie46 I think this is a valid issue. Why do the following two produce the same result?

pl.DataFrame({"a": [1], "b": [2]}).select(
    pl.concat_list("a", "b")
)
# shape: (1, 1)
# ┌───────────┐
# │ a         │
# │ ---       │
# │ list[i64] │
# ╞═══════════╡
# │ [1, 2]    │
# └───────────┘

pl.DataFrame({"a": [[1]], "b": [[2]]}).select(  # note the [[1]]
    pl.concat_list("a", "b")
)
# shape: (1, 1)
# ┌───────────┐
# │ a         │
# │ ---       │
# │ list[i64] │
# ╞═══════════╡
# │ [1, 2]    │
# └───────────┘

The documentation says "Horizontally concatenate columns into a single list column." If the columns are lists, then they should form a list of lists.

Edit: I just noticed there is more to the documentation in 1.0 which isn't on the current 0.2 documentation, that clarifies.

from polars.

ritchie46 avatar ritchie46 commented on August 18, 2024

It is a concat list operation. It concats the lists. If you want to create an extra level of nesting you need to implode() the arguments.

from polars.

mcrumiller avatar mcrumiller commented on August 18, 2024

FYI I feel that pl.list would be a better name if the intended behavior is what's written in the description. I agree that the word "concat" implies that you take existing lists and concatenate them together, but I believe the intent is to take existing columns and concanate them into a list, in which case the inner dtype of the list should be common supertype of the columns.

from polars.

ritchie46 avatar ritchie46 commented on August 18, 2024

The initial implosion is because there isn't any list yet. So in order to concat them, they are imploded.

I think we should improve the description here.

from polars.

mcrumiller avatar mcrumiller commented on August 18, 2024

@ritchie46 the description's improved in the 1.0 docs, I had missed that.

from polars.

NickCrews avatar NickCrews commented on August 18, 2024

@mcrumiller pinpoints my exact confusion. I agree there should be two functions, one that is a constructor as in
Iterable[T] -> List[T] , and another which concatenates Iterable[List[T]] -> List[T]

from polars.

NickCrews avatar NickCrews commented on August 18, 2024

I'm looking for the constructor. What could I use for that currently?

from polars.

mcrumiller avatar mcrumiller commented on August 18, 2024

Hi @NickCrews, can you be a little more specific about what you want to do?

from polars.

NickCrews avatar NickCrews commented on August 18, 2024

Yes, but I'll get to it in an hour or two once I can get back to my computer

from polars.

NickCrews avatar NickCrews commented on August 18, 2024

Actually, I think we should move all discussion to #8510.

Specifically, I responded in this comment in that issue.

from polars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.