Giter Club home page Giter Club logo

Comments (13)

ritchie46 avatar ritchie46 commented on June 13, 2024 1

It's pity that you are so lazy and not familiar with your own cookbook

It is not written by him. In any case it's a community efford. I would appreciate if you would stay respectful to our contributors they do this in their free time.

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

I could probably check this out soon if no one else has gotten to it.

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

hey @yanyu2015! Could you point me in the right direction for this?

  1. I don't want to have to search around for the first example, so a link would be perfect.
  2. Not sure I see what you'd like to change for the second snippet.
  3. Manual Sum error should be fixed in #147

from polars-book.

yanyu2015 avatar yanyu2015 commented on June 13, 2024

1 It's pity that you are not familiar with your own cookbook. the link.
2 please give which specify data you use, it's ambiguous, are you sure that code can work well?

from polars-book.

yanyu2015 avatar yanyu2015 commented on June 13, 2024

I am sorry for my rude words. But I also do this in my free time, polars is great and I want to contribute to it.
I writed this issue TWICE before 14 days ago, but until today no one has fixed it or even knows where it is, which makes me feel uncomfortable. Cookbook is the most authoritative source for every beginner, and I think we should take it seriously. When I recommended polars to my friends, they felt that the cookbook was not friendly enough, which made me feel embarrassed.

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

Then let's improve it!

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

@yanyu2015

1 It's pity that you are not familiar with your own cookbook. the link.

Done!

2 please give which specify data you use, it's ambiguous, are you sure that code can work well?

Hmm.. curious. Maybe I'm looking at the wrong spot here as well, so correct me if I'm wrong, but there's a link to US Congress dataset above the snippet. I see that it's not a link in your screenshot though.

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

Noticing there might be similar feedback from #120.

Getting the US congress dataset code sample on GroupBy page (3.3) is very unclear about how to replicate ("from .dataset import dataset" doesn't work and is rather unclear how to execute other than that snippet)

Edit: rereading that it seems more like a user error.

from polars-book.

yanyu2015 avatar yanyu2015 commented on June 13, 2024

you are nice.
To the 2 point, the reason is the from .dataset import dataset seems not work. and US Congress dataset is right, but there are so many datasets so taht people may not know which one is the right dataset the cookbook used. I try legislators-current and other dataset. If someone cannot replicate the result as the page presented they may feel confused.

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

Here's the dataset that's imported

import polars as pl
url = "https://theunitedstates.io/congress-legislators/legislators-historical.csv"
dtypes = {
"first_name": pl.Categorical,
"gender": pl.Categorical,
"type": pl.Categorical,
"state": pl.Categorical,
"party": pl.Categorical,
}
dataset = pl.read_csv(url, dtype=dtypes).with_column(pl.col("birthday").str.strptime(pl.Date, strict=False))

from polars-book.

yanyu2015 avatar yanyu2015 commented on June 13, 2024

I try the code again.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_35972/3485124543.py in <module>
      1 import polars as pl
      2 
----> 3 from .dataset import dataset
      4 
      5 q = (

ImportError: attempted relative import with no known parent package

I see you have trid to fix it in #120

from polars-book.

cnpryer avatar cnpryer commented on June 13, 2024

Try

import polars as pl

url = "https://theunitedstates.io/congress-legislators/legislators-historical.csv"

dtypes = {
    "first_name": pl.Categorical,
    "gender": pl.Categorical,
    "type": pl.Categorical,
    "state": pl.Categorical,
    "party": pl.Categorical,
}

dataset = pl.read_csv(url, dtype=dtypes).with_column(
    pl.col("birthday").str.strptime(pl.Date, strict=False)
)

q = (
    dataset.lazy()
    .groupby("first_name")
    .agg(
        [
            pl.count(),
            pl.col("gender").list(),
            pl.first("last_name"),
        ]
    )
    .sort("count", reverse=True)
    .limit(5)
)

df = q.collect()

from polars-book.

yanyu2015 avatar yanyu2015 commented on June 13, 2024

ok, it works well. Let's close this issue.

from polars-book.

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.