Pandas DataFrame子类,强制执行结构并可以自组织。

typeddfs的Python项目详细描述


类型化数据帧

Latest version on PyPiSupported Python versionsDocumentation statusBuild & testLicenseBuild statusMaintainabilityCoverage Status

Pandas DataFrame子类,强制执行结构并可以自组织。 因为您的函数不能完全接受any数据帧。在

子类数据帧可以具有必需的和/或可选的列和索引, 并支持定制需求。 列会自动转换为索引, 这意味着^{str1}$read_csv和{}总是逆的。 MyDf.read_csv(mydf.to_csv())只是mydf。在

数据帧会很好地显示在Jupyter笔记本上, 并添加了一些方便的方法,如sort_natural和{}。 See the docs了解更多信息。在

CSV的简单示例如下:

keyvaluenote
abc123?
fromtypeddfsimportTypedDfs# Build me a Key-Value-Note class!KeyValue=(TypedDfs.typed('KeyValue')# typed means enforced requirements.require('key',index=True)# automagically make this an index.require('value')# required.reserve('note')# permitted but not required.strict()# don't allow other columns).build()# This will self-organize and use 'key' as the index:df=KeyValue.read_csv('example.csv')# For fun, let's write it and read it back:df.to_csv('remke.csv')df=KeyValue('remake.csv')print(df.index_names(),df.column_names())# ['key'], ['value', 'note']# And now, we can type a function to require a KeyValue,# and let it raise an `InvalidDfError` (here, a `MissingColumnError`):defmy_special_function(df:KeyValue)->float:returnKeyValue(df)['value'].sum()

所有正常的数据帧方法都可用。 使用.untyped().vanilla()生成不强制要求的脱类型副本。在

欢迎使用New issues和拉取请求。 请参考contributing guide。 用Tyrannosaurus生成。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Spring 4升级后未加载java应用程序上下文   java Android 2.3.3 internet可以在我的Galaxy S上运行,但不能在我的Galaxy选项卡上运行?(许可?)   java通过不改变其原始位置对大小写字母进行排序   java Spring Boot一直在破坏我的电脑。。。sts的最佳配置是什么。Windows 10上的ini文件?   css Java Spring+引导问题   java Jackson将GeoJsonPoint序列化为纬度/经度   xml Java Transformer:如何将其结果生成OutputStream?   java如何更改字体、文本大小和设置文本位置?   在JavaSpringHibernate3.6.3中,如何告诉一个方法等待,直到获得锁,以及如何重试失败的事务?   java安卓服务代替线程   Java Swing使用鼠标移动JFrame