Comments (2)
Alternatively, make the library an extension of pandas.core.generic.NDFrame, and then these statistics can be ran against Series as well as DataFrames, and they don't have to be instantiated as a separate object. This would allow you to do an import and use it directly on a DataFrame:
import pandas as pd
from pandas.core.generic import NDFrame
def monkeypatch_method(cls):
def decorator(func):
setattr(cls, func.__name__, func)
return func
return decorator
@monkeypatch_method(NDFrame)
def summary(self):
"""Does the same as dfs = DataFrameSummary(self); dfs[column]"""
dfs = DataFrameSummary(self)
dfs.__getitem__(self,column)
Then it could be used like this:
import pandas as pd
import pandas_summary
df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
'num_wings': [2, 0, 0, 0],
'num_specimen_seen': [10, 2, 1, 8]},
index=['falcon', 'dog', 'spider', 'fish'])
df['num_legs'].summary()
instead of:
import pandas as pd
from pandas_summary import DataFrameSummary
df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
'num_wings': [2, 0, 0, 0],
'num_specimen_seen': [10, 2, 1, 8]},
index=['falcon', 'dog', 'spider', 'fish'])
dfs = DataFrameSummary(df)
dfs['num_legs']
The above code is untested, but generally correct with how it'd be exposed and used. I think this makes more sense than using properties and is more like DataFrame.describe() in how it is called, but providing the additional information DataFrameSummary class provides... the summary. It's just more tightly integrated.
Developed as an extension library like this, it could be brought to Pandas in the future more easily.
from traceml.
@rbeesley this is an interesting idea.
from traceml.
Related Issues (14)
- Python 3 support HOT 4
- pandas 0.23.0 changed how types are handled
- Patch level went d?
- Patch level went down?
- PyPI is considering 0.0.41 as latest version HOT 1
- ValueError: supplied range of [0.0, inf] is not finite
- bad import
- Error in Pytorch Lightning Callback method.
- support for non-hashable objects HOT 2
- Add LICENSE to MANIFEST.in HOT 1
- Merge this in pandas-profiling? HOT 3
- Show missing columns only
- Use more than one thread
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traceml.