home.social

#pandas — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #pandas, aggregated by home.social.

  1. In 3.1, reading CSV is multi-threaded, using up to 6 by default.

    You can change it temporarily with mode.max_threads:

    with pd.option_context('mode.max_threads', 10):
    df = pd.read_csv('bigfile.csv')

    Note: More threads aren't always faster!

  2. Want to set an option in , but just temporarily? You can use option_context:

    with pd.option_context('display.precision', 2):
    print(s/3)

    Within the "with" block, the display precision is 2. But outside -- before or after -- it is the default.

  3. There are tons of config options in . Set them with pd.set_option:

    pd.set_option('display.precision', 2)

    Now floats in a series or data frame will have 2 digits after the decimal.

    Retrieve the value with "get_option":

    pd.get_option('display.precision')

Share on Mastodon

Enter the server where you have an account.