{"id":29019724,"url":"https://github.com/mayasmess/pandas-oop","last_synced_at":"2025-06-26T01:01:54.197Z","repository":{"id":42484746,"uuid":"475156458","full_name":"MayasMess/pandas-oop","owner":"MayasMess","description":"⚡️ Pandas dataframes with object oriented programming style (not maintained)","archived":false,"fork":false,"pushed_at":"2024-03-17T14:20:09.000Z","size":209,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T20:36:46.172Z","etag":null,"topics":["pandas","python","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MayasMess.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-03-28T19:48:57.000Z","updated_at":"2024-12-30T22:26:49.000Z","dependencies_parsed_at":"2024-03-17T15:25:05.468Z","dependency_job_id":"820c1f36-8d47-48dd-bf9d-e88665107b2a","html_url":"https://github.com/MayasMess/pandas-oop","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/MayasMess/pandas-oop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayasMess%2Fpandas-oop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayasMess%2Fpandas-oop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayasMess%2Fpandas-oop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayasMess%2Fpandas-oop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MayasMess","download_url":"https://codeload.github.com/MayasMess/pandas-oop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayasMess%2Fpandas-oop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261978831,"owners_count":23239413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pandas","python","sql"],"created_at":"2025-06-26T01:00:52.679Z","updated_at":"2025-06-26T01:01:54.119Z","avatar_url":"https://github.com/MayasMess.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![image](static/images/poop_sticker.png)\n# Pandas-Oop (not maintained, see https://github.com/MayasMess/panorma it's simpler)\n(Also known as Poop), is a package that uses Pandas dataframes with object oriented programming style\n\nInstallation:\n- \n\n```shell script\n  pip install pandas-oop\n```\n\nSome examples\n-\n\n```python\nfrom pandas_oop import models\nfrom pandas_oop.fields import StringColumn, IntegerColumn, FloatColumn, DateColumn, BoolColumn\n```\n```python\nDB_CONNECTION = models.Connection('sqlite:///pandas_oop.db') # this is the same con_string for sqlalchemy engine\n```\n```python\n@models.sql(table='people', con=DB_CONNECTION) # Use this decorator if you want to connect your class to a database\n@models.Data\nclass People(models.DataFrame):\n    name = StringColumn(unique=True)\n    age = IntegerColumn()\n    money = FloatColumn(target_name=\"coins\") # target_name if the name in the csv or table is coins and you want to have a different variable name\n    insertion_date = DateColumn(format='%d-%m-%Y')\n    is_staff = BoolColumn(true='yes', false='no')\n```\n\nNow when instantiating this class, it will return a custom dataframe with all the functionalities of a Pandas\ndataframe and some others\n\n```python\npeople = People()\n\"\"\"-----------------------------------------------------------\"\"\"\npeople = People(from_csv=DATA_FILE, delimiter=\";\")\n\"\"\"-----------------------------------------------------------\"\"\"\npeople = People(from_sql_query='select * from people')\n\"\"\"-----------------------------------------------------------\"\"\"\npeople = People(from_df=some_dataframe)\n\"\"\"-----------------------------------------------------------\"\"\"\npeople = People(from_iterator=some_function_that_yield_values)\n\"\"\"-----------------------------------------------------------\"\"\" \nfor people_chunk in People(from_csv=DATA_FILE, delimiter=\";\", chunksize=10):\n    ...\n```\nexample of function that yield values:\n\n```python\ndef some_function_that_yield_values():\n    while something:\n        ...\n        yield name, age, money, insertion_date, is_staff\n```\n\n![image](static/images/df.png)\n\nYou can also save it to the database with the save() method (if the dtypes of the columns change, this will raise a \nValidationError):\n\n```python\npeople.save()\n```\n\nYou can upsert to the database and this will automatically look at the unique fields that were declared in the class\n\n```python\npeople.save(if_row_exists='update')\nor\npeople.save(if_row_exists='ignore')\n```\n\nIf you want to revalidate your dataframe (convert the columns dtypes to the type that was declared in the class), you can \ncall the validate() method:\n\n```python\npeople.validate()\n```\n\nYou can also validate from another class. For example, you can do something like this:  \n\n```python\npeople = People(from_csv=DATA_FILE)\njobs = Jobs(from_sql_query='select * from jobs')\npeople_with_jobs = people.merge(jobs, on='name').validate(from_class=PeopleWithJobs)\n```\n\nThis is the list of the overriten methods that return a pandas_oop custom dataframe\n- 'isnull'\n- 'head'\n- 'abs'\n- 'merge'\n- 'loc' and dataframe slicing\n\nI will add more and more methods on this list.\n\n\nNew features\n-\nAlembic Database migration support added:\n- On your main application package, import Base (this is a declarative_base from sqlalchemy)\n```python\nfrom pandas_oop import Base\n```\n- Add this configuration on the env.py file of your alembic config\n```python\nfrom your_app import Base\ntarget_metadata = Base.metadata\n```\n- And finaly, update your database url on your alembic.ini file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayasmess%2Fpandas-oop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayasmess%2Fpandas-oop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayasmess%2Fpandas-oop/lists"}