Pandas - Sets: Set-oriented Operations in Pandas
Project description
Pandas Sets: Set-oriented Operations in Pandas
If you store standard Python set
s in your Series
or DataFrame
objects, you'll find this useful.
The pandas_sets
package adds a .set
accessor to any pandas Series
object;
it's like .dt
for datetime
or .str
for string
, but for set
.
It exposes all public methods available in the standard set
.
Installation
pip install pandas-sets
Just import the pandas_sets
package and it will register a .set
accessor to any Series
object.
import pandas_sets
Examples
import pandas_sets
import pandas as pd
df = pd.DataFrame({'post': [1, 2, 3, 4],
'tags': [{'python', 'pandas'}, {'philosophy', 'strategy'}, {'scikit-learn'}, {'pandas'}]
})
pandas_posts = df[df.tags.set.contains('pandas')]
pandas_posts.tags.set.add('data')
pandas_posts.tags.set.update({'data', 'analysis'})
pandas_posts.tags.set.len()
Notes
- The implementation is primitive for now. It's based heavily on the pandas' core
StringMethods
implementation. - The public API has been tested for most expected scenarios.
- The API will need to be extended to handle
NA
values appropriately.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pandas-sets-0.1.0.tar.gz
(4.1 kB
view hashes)
Built Distributions
pandas_sets-0.1.0-py3.7.egg
(8.5 kB
view hashes)
Close
Hashes for pandas_sets-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b607c56090c9e802a02b43140ede6e723e4efc3cf2154c33b36e2704dc54e6e8 |
|
MD5 | 411e6021d54b43f403528d7f646e5342 |
|
BLAKE2b-256 | d69c4be9e6cd06d7d65a8b29cc3f64cf35fbb910b97522fb402f05621a9ab9b3 |