Giter VIP home page Giter VIP logo

tidybear's Introduction

Hi there ๐Ÿ‘‹

tidybear's People

Contributors

mbmackenzie avatar

Watchers

 avatar  avatar

Forkers

shism2

tidybear's Issues

TidySelectors do no support columns names that are numeric

Problem

Some tidy selectors do no work on column names that are numeric because internally they use string methods.

Expected Behavior

A tidy selector should convert names to strings in cases where string methods are used apply the filters and convert them back.

Example

import pandas as pd
import tidybear as tb
from tidybear.selectors import starts_with

data = pd.DataFrame(
    {
        "THING": ["A", "A", "B", "B"],
        "YEAR": [2021, 2022, 2021, 2022],
        "VALUE": [1, 2, 3, 4],
    }
)

tmp = tb.pivot_wider(data, names_from="YEAR", values_from="VALUE")
tb.pivot_longer(tmp, starts_with("20"), names_to="YEAR", values_to="VALUE")

GOT

    156 def selector(columns: Iterable[str]) -> List[str]:
--> 157     return [c for c in columns if c.startswith(pattern)]

AttributeError: 'int' object has no attribute 'startswith'

WANTED

  THING  YEAR  VALUE
0     A  2021      1
1     A  2022      2
2     B  2021      3
3     B  2022      4

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.