daler / pybedtools

Python wrapper -- and more -- for BEDTools (bioinformatics tools for "genome arithmetic")
http://daler.github.io/pybedtools
Other
297 stars 103 forks source link

Add support for polars dataframes #388

Open DevangThakkar opened 1 year ago

DevangThakkar commented 1 year ago

This PR fixes https://github.com/daler/pybedtools/issues/376 and support for polars dataframes. Users can now convert a BedTool object to a polars dataframe using the to_polars_dataframe method, and create a BedTool object from a polars dataframe using the from_polars_dataframe method. The functions follow the style of the to_dataframe and from_dataframe functions with required modifications for polars syntax.

I have also added docs for the functionality to export to/import from pandas/polars dataframes. I have not worked with reStructuredText before so it might have some visual glitches.

I have also added some tests for both functions in the test_from_polars_dataframe function in test_1.py.

Let me know what you think!

DevangThakkar commented 1 year ago

Hi @daler , please let me know if you have any thoughts on this - I think it would be useful to have this functionality for pybedtools. Happy to make changes as needed. :)