This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Get freadked out with handling data type?

int <-> np.int64, np.int32 <-> float <-> np.float32, np.float64 <-> np.nan
str <-> datetime <-> np.datetime64 <-> pd.tslib.Timestamp
int <-> str <-> float
...

It’s completely a disaster and always happen if you do a lots of data wrangling using numpy and pandas.

You may also have a crawler harvesting data from internet, but you have to convert it to structured data, so you have to manually handle the None returns, string to int, float, datetime.

Trust me, typarse can save you from these.

Quick Link:

Quick Guide

First let’s import typarse:

>>> from typarse import TypeParser
>>> p = TypeParser()

Let’s see how it works:

>>> p.parse_int(1)
1

>>> p.parse_int(1.0000001) # fix the decimal accuracy error
1

>>> p.parse_int(0.9999999) # fix the decimal accuracy error
1

>>> p.parse_int(np.int64(2 ** 48)) # 281474976710656 in python3
281474976710656L

>>> p.parse_int("1")
1

>>> p.parse_int("1.001")
1

>>> p.parse_int("0.999")
1

for datetime-like type (includes datetime.datetime, numpy.datetime64, pd.tslib.Timestamp ), we get the timestamp, for date-like type, we get the days from ordinary.

>>> from datetime import datetime
>>> p.parse_int(datetime(1969, 12, 31, 19, 0, 1))
1

>>> p.parse_int(date(1, 1, 1)))
1

typarse has a powerful feature can automatically extract numbers from string. For example you have something like: "temp is 13 degree" or "my house is 2540 sqft", you just want to get the numbers. Of course this features also works for float.

>>> p.parse_int(" a1b ")
1

>>> p.parse_int(" a1.001c ")
1

If you don’t want this feature and worry about mistakes, you can call this to disable that:

>>> p.setting.extract_number_from_text = False # use True when you need it again

More Usage Example

So for more examples about parse_float, parse_str, parse_datetime, parse_date, go check these links:

For datetime and date parser, if my parser doens’t recognize the format, you can:

  1. submit issue, request more template
  2. add your own template to the source code. datetime format reference is here.

Download and Install

typarse requires numpy >= 1.6.1, pandas >= 0.12.1.

typarse is released on PyPI, so all you need is:

$ pip install typarse

To upgrade to latest version:

$ pip install --upgrade typarse

If you want to build the source by your self, download the source code and:

$ cd typarse-project
$ python setup.py build
$ python setup.py install
Release History

Release History

0.0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
typarse-0.0.2.zip (24.4 kB) Copy SHA256 Checksum SHA256 Source Oct 1, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting