Copy disabled (too large)
Download .txt
Showing preview only (14,609K chars total). Download the full file to get everything.
Repository: JacksonWuxs/DaPy
Branch: master
Commit: b2bf72707ffc
Files: 122
Total size: 13.9 MB
Directory structure:
gitextract_ackf5hh1/
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── bug_report.md
│ └── feature_request.md
├── DaPy/
│ ├── __init__.py
│ ├── core/
│ │ ├── DataSet.py
│ │ ├── __init__.py
│ │ ├── base/
│ │ │ ├── BaseSheet.py
│ │ │ ├── DapyObject.py
│ │ │ ├── IndexArray.py
│ │ │ ├── LinkedArray.py
│ │ │ ├── Matrix.py
│ │ │ ├── Series.py
│ │ │ ├── Sheet.py
│ │ │ ├── Views/
│ │ │ │ └── __init__.py
│ │ │ ├── __init__.py
│ │ │ ├── absents/
│ │ │ │ └── Frame.py
│ │ │ ├── constant.py
│ │ │ ├── row.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ ├── py_string_transfer.py
│ │ │ ├── string_transfer.pyd
│ │ │ ├── utils_2to3.py
│ │ │ ├── utils_grammar_parser.py
│ │ │ ├── utils_isfunc.py
│ │ │ ├── utils_join_table.py
│ │ │ ├── utils_regression.py
│ │ │ ├── utils_str_patterns.py
│ │ │ ├── utils_str_transfer.py
│ │ │ └── utils_toolkits.py
│ │ ├── io.py
│ │ └── sqlparser.py
│ ├── datasets/
│ │ ├── __init__.py
│ │ ├── adult/
│ │ │ ├── adult.csv
│ │ │ └── data.csv
│ │ ├── example/
│ │ │ └── sample.csv
│ │ ├── iris/
│ │ │ ├── data.csv
│ │ │ └── info.txt
│ │ ├── lenses/
│ │ │ └── data.txt
│ │ └── wine/
│ │ ├── data.csv
│ │ └── info.txt
│ ├── doc/
│ │ ├── Quick Start.md
│ │ ├── Quick Start_Chinese.md
│ │ ├── README.md
│ │ └── README_Chinese.md
│ ├── io.py
│ ├── matlib.py
│ ├── methods/
│ │ ├── __init__.py
│ │ ├── classifiers/
│ │ │ ├── __init__.py
│ │ │ ├── classifier.py
│ │ │ ├── linear_models.py
│ │ │ ├── mlp.py
│ │ │ └── tree.py
│ │ ├── core/
│ │ │ ├── __init__.py
│ │ │ ├── base/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── activators.py
│ │ │ │ ├── layers.py
│ │ │ │ ├── models.py
│ │ │ │ └── utils.py
│ │ │ ├── bp_model.py
│ │ │ ├── linear_model.py
│ │ │ ├── multilayer_perceptron.py
│ │ │ ├── pagerank.py
│ │ │ └── tfidf.py
│ │ ├── evaluator.py
│ │ ├── regressors/
│ │ │ ├── __init__.py
│ │ │ └── lr.py
│ │ ├── statistic/
│ │ │ ├── __init__.py
│ │ │ ├── compare_position.py
│ │ │ ├── compare_scaler.py
│ │ │ ├── discriminant_analysis.py
│ │ │ ├── distribution.py
│ │ │ └── kMeans.py
│ │ └── utils.py
│ ├── operation.py
│ └── tests/
│ ├── __init__.py
│ ├── scripts/
│ │ ├── performance.py
│ │ ├── test_lr.py
│ │ ├── test_matrix.py
│ │ ├── test_merge.py
│ │ └── test_methods.py
│ ├── test_CoreBaseIndexArray.py
│ ├── test_CoreBaseSeries.py
│ ├── test_CoreBaseSheet.py
│ ├── test_CoreBaseTools.py
│ └── test_methods.py
├── README.md
├── README_Chinese.md
├── _config.yml
├── clib/
│ ├── build/
│ │ └── temp.win-amd64-3.6/
│ │ └── Release/
│ │ ├── string_transfer.cp36-win_amd64.exp
│ │ ├── string_transfer.cp36-win_amd64.lib
│ │ └── string_transfer.obj
│ ├── io.c
│ ├── io.html
│ ├── io.pyx
│ ├── math.c
│ ├── math.html
│ ├── math.pyx
│ ├── setup.py
│ ├── string_transfer.c
│ ├── string_transfer.html
│ └── string_transfer.pyx
├── doc/
│ ├── DaPy Framework.xlsx
│ ├── Guide Book/
│ │ ├── Chinese/
│ │ │ ├── README.md
│ │ │ └── 快速开始.md
│ │ ├── English/
│ │ │ ├── Features.md
│ │ │ ├── Introduction.md
│ │ │ ├── Performance Test for DaPy.md
│ │ │ └── Quick Start.md
│ │ └── README.md
│ ├── Quick Start/
│ │ ├── Chinese.md
│ │ ├── English.md
│ │ └── get-start.py
│ ├── Reading/
│ │ ├── DaPy - Introduction.txt
│ │ ├── DaPy - Smooth Data Mining Experience.md
│ │ ├── DaPy - 丝滑般实现数据分析.md
│ │ └── DaPy - 简介.md
│ ├── homepage/
│ │ ├── License.md
│ │ ├── TODO.md
│ │ └── Version-Log.md
│ ├── info.txt
│ └── material/
│ ├── DaPy.ai
│ └── DaPy.psd
└── setup.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: DaPy/__init__.py
================================================
# user/bin/python
#########################################
# Author : Xuansheng Wu
# Email : wuxsmail@163.com
# created : 2017-11-01
# Last modified : 2020-02-04
# Filename : DaPy.__init__.py
# Description : initial file for DaPy
#########################################
'''
Data Analysis Library for Humans.
DaPy module is a fundemantal data processing tool, which helps you
readily process and analysis data. DaPy offers a series of humane data
structures, including but not limiting in SeriesSet, Frame and DataSet. Moreover,
it implements some basic data analysis algorithms, such as Multilayer
Perceptrons, One way ANOVA and Linear Regression. With DaPy help,
data scientists can handle their data and complete the analysis task easily.
Enjoy the tour in data mining!
:Copyright (C) 2018 - 2020 Xuansheng Wu.
:License: GNU 3.0, see LICENSE for more details.
'''
__all__ = [ 'SeriesSet', 'mat', 'DataSet', 'datasets', 'methods', 'Table',
'exp', 'dot', 'multiply', 'zeros', 'ones', 'C', 'P', 'add',
'diag', 'log', 'boxcox', 'cov', 'corr', 'frequency', 'quantiles',
'distribution', 'describe', 'mean', 'abs', 'max', 'nan', 'inf',
'sum', 'diff', 'read', 'encode', 'save', 'delete', 'column_stack',
'merge', 'row_stack', 'boxcox', 'show_time', 'get_dummies']
from .core import SeriesSet, DataSet, Matrix, Series
from .core import nan, inf, argsort
from .matlib import exp, dot, multiply, zeros, ones, C, P, add, diag, log, boxcox
from .matlib import cov, corr, frequency, quantiles, _sum as sum, diff, cumsum
from .matlib import distribution, describe, mean, _abs as abs, _max as max
from .io import read, encode, save
from .operation import delete, column_stack, row_stack, merge, concatenate
from .operation import get_dummies, get_ranks, _repeat as repeat
from warnings import warn
from datetime import datetime
Table = SeriesSet
mat = Matrix
__title__ = 'DaPy'
__description__ = 'Enjoy the tour in data mining !'
__url__ = 'http://dapy.kitgram.cn'
__version__ = '1.14.1'
__build__ = 0x20200214
__author__ = 'Xuansheng Wu (wuxsmail@163.com)'
__license__ = '''DaPy Copyright (C) 2018 - 2020 WU Xuansheng'+\
This program comes with ABSOLUTELY NO WARRANTY;
for details type `show w'.This is free software,
and you are welcome to redistribute it under certain
conditions; type `show c' for details.'''
__copyright__ = 'Copyright 2018-2020 Xuansheng Wu.'
__date__ = datetime(2020, 2, 14)
def _unittests():
from unittest import TestSuite, defaultTestLoader, TextTestRunner
_tests = TestSuite()
for case in defaultTestLoader.discover('.', 'test_*.py'):
_tests.addTests(case)
tester = TextTestRunner()
tester.run(_tests)
if 'Alpha' in __version__:
print('In developing edition of DaPy-%s' % __version__)
================================================
FILE: DaPy/core/DataSet.py
================================================
from collections import Counter, Iterator, namedtuple
from copy import copy
from functools import wraps
from operator import methodcaller
from os.path import isfile
from pprint import pprint
from time import clock
from .base import (PYTHON3, Frame, LogErr, LogInfo, Matrix, Series,
SeriesSet, auto_plus_one, is_iter, is_seq, is_str,
map, pickle, range, zip)
from .io import (parse_addr, parse_db, parse_excel, parse_html,
parse_mysql_server, parse_sav, parse_sql, write_db,
write_html, write_sql, write_txt, write_xls)
__all__ = ['DataSet']
SHOW_LOG = True
def timer(func):
@wraps(func)
def timer_func(self, *args, **kwrds):
start = clock()
ret = func(self, *args, **kwrds)
if self.logging is True:
name, spent = func.__name__, clock() - start
LogInfo('%s() in %.3fs.' % (name, spent))
return ret
return timer_func
def operater(callfunc):
callfunc = getattr(SeriesSet, callfunc.__name__)
@wraps(callfunc)
def operate_func(self, *args, **kwrds):
ret_set = DataSet()
for name, sheet in zip(self._sheets, self._data):
ret = callfunc(sheet, *args, **kwrds)
if isinstance(ret, (SeriesSet, Series, list, tuple)):
ret_set._add(ret, name)
elif isinstance(ret, (dict, Counter)):
for name_, ret_ in ret.items():
ret_set._add(ret_, name_)
return ret_set
return operate_func
class DataSet(object):
'''A easy-to-use functional data structure similar to MySQL database
DataSet is one of the fundamantal data structure in DaPy.
It supports users easily to opearte any data structure in
a same way with Pythonic Syntax. Additionally, it has
logging function.
Attrbutes
---------
data : list
a list stored all the sheets inside.
sheets : list
a list stored all the names of each sheet.
types : list
the list stored all the type of each sheet.
Examples
--------
>>> import DaPy as dp
>>> data = dp.DataSet([[1, 2, 3], [2, 3, 4]])
>>> data.tocol()
>>> data
sheet:sheet0
============
Col_0: <1, 2>
Col_1: <2, 3>
Col_2: <3, 4>
>>> data.info
sheet:sheet0
============
1. Structure: DaPy.SeriesSet
2. Dimensions: Ln=2 | Col=3
3. Miss Value: 0 elements
4. Describe:
Title | Miss | Min | Max | Mean | Std |Dtype
-------+------+-----+-----+------+------+-----
Col_0 | 0 | 1 | 2 | 1.50 | 0.71 | list
Col_1 | 0 | 2 | 3 | 2.50 | 0.71 | list
Col_2 | 0 | 3 | 4 | 3.50 | 0.71 | list
==============================================
'''
__all__ = ['data', 'columns', 'sheets','info', 'add', 'append', 'append_col', 'info',
'count', 'count_element', 'pop_miss_value', 'size', 'shape',
'extend', 'insert', 'insert_col', 'pick', 'pop', 'pop_col',
'normalized', 'read', 'reverse', 'replace', 'shuffles','corr',
'sort', 'save', 'tomat', 'toframe', 'tocol', 'show', 'log']
def __init__(self, obj=None, sheet='sheet0', log=SHOW_LOG):
'''
Parameter
---------
obj : array-like (default=None)
initialized your data from a data structure, such as dict(), list()
Frame(), SeriesSet(), Matrix(), DataSet().
sheet : str (default='sheet0')
the name of first sheet inside.
log : bool (default=True)
show the time consuming for each operation
'''
self.logging = log
if obj is None:
self._data = []
self._sheets = []
self._types = []
elif (not is_iter(obj)) and not isinstance(obj, str):
raise TypeError('DataSet can not store this object.')
elif isinstance(obj, DataSet):
self._data = copy(obj._data)
self._sheets = copy(obj._sheets)
self._types = copy(obj._types)
elif isinstance(obj, (Matrix, SeriesSet, Frame)):
self._data = [obj, ]
self._sheets = [str(sheet), ]
self._types = [type(sheet), ]
elif isinstance(sheet, str):
self._data = [obj, ]
self._sheets = [str(sheet), ]
self._types = [type(obj), ]
else:
self._data = list(obj)
self._sheets = list(map(str, sheet))
self._types = list(map(type, self._data))
if len(set(self._sheets)) != len(self._data):
raise ValueError("the number of sheets' names do not enough.")
@property
def data(self):
if len(self._data) == 1:
return self._data[0]
return self._data
@property
def columns(self):
'''names of columns of each table'''
if len(self._data) > 1:
new_ = list()
for i, data in enumerate(self._data):
if hasattr(data, 'columns'):
new_.append([self._sheets[i]] + data.columns)
else:
new_.append([self._sheets[i], None])
new_title = ['sheet name']
new_title.extend(['title_%d'%i for i in range(1, len(max(new_, key=len)))])
return SeriesSet(new_, new_title)
if len(self._data) == 1:
if hasattr(self._data[0], 'columns'):
return self._data[0].columns
return None
@property
def logging(self):
return self._log
@logging.setter
def logging(self, value):
if value is not True:
self._log = False
else:
self._log = True
@property
def level(self):
return len(self._data)
@columns.setter
def columns(self, value):
for data in self._data:
if hasattr(data, 'columns'):
data.columns = value
@property
def sheets(self):
return self._sheets
@sheets.setter
def sheets(self, other):
if isinstance(other, str):
self._sheets = [self._check_sheet_new_name(other) for i in range(len(self._sheets))]
elif is_iter(other):
if len(set(other)) == len(self._sheets):
self._sheets = []
self._sheets = [self._check_sheet_new_name(item) for item in other]
else:
raise ValueError('the names size does not match the size of '+\
'sheets inside the DataSet')
else:
raise ValueError('unrecognized symbol as %s'%other)
@property
def shape(self):
temp = SeriesSet(None, ['Level', 'Sheet', 'Ln', 'Col'], nan='-')
for i, (sheet, data) in enumerate(zip(self._sheets, self._data)):
if hasattr(data, 'shape'):
temp.append([i, sheet] + list(data.shape))
else:
temp.append((i, sheet, len(data)))
return temp
@property
def info(self):
for i, data in enumerate(self._data):
print('sheet:' + self._sheets[i])
print('=' * (len(self._sheets[i]) + 6))
if isinstance(data, (Frame, SeriesSet)):
data.info
else:
print('%s has no info() function'%type(data))
return None
def __getattr__(self, name):
if name in self._sheets:
return self.__getitem__(name)
temp = DataSet()
for sheet, data in zip(self._sheets, self._data):
if hasattr(data, name) or\
(hasattr(data, 'columns') and name in data.columns):
attr = methodcaller(name)
try:
temp._add(attr(data), sheet)
except TypeError:
temp._add(getattr(data, name), sheet)
assert temp.level != 0, "DataSet has no sheet `%s`'" % name
return temp
def _check_col_ind_str(self, ind):
assert ind in self._sheets, "'%s' is not a sheet name" % ind
return self._sheets.index(ind)
def _check_col_ind_int(self, ind):
if ind < 0:
sheet += self.level - 1
assert 0 <= ind < self.level, "'%s' is not exist." % ind
return ind
def _check_sheet_new_name(self, new_name):
new_name = str(new_name)
if not new_name:
return self._check_sheet_new_name('sheet_%d' % len(self._sheets))
if new_name not in self._sheets:
return new_name
return auto_plus_one(self._sheets, new_name)
def _check_sheet_index_slice(self, i, j):
if is_str(i) or is_str(j):
if i is not None:
i = self._check_col_ind_str(i)
if j is not None:
j = self._check_col_ind_int(j)
i = self._check_col_ind_int(i) + 1
j = self._check_col_ind_int(j) + 1
return range(len(self._sheets))[slice(i, j)]
def _check_sheet_index(self, sheet):
'''return a list of sheet indexes'''
if sheet is None:
return range(len(self._data))
if is_str(sheet):
return [self._check_col_ind_str(sheet)]
if isinstance(sheet, slice):
return self._check_sheet_index_slice(sheet.start, sheet.stop)
if isinstance(sheet, int):
return [self._check_col_ind_int(sheet)]
if isinstance(sheet, (list, tuple)):
return [self._check_sheet_index(_) for _ in sheet]
def __getstate__(self):
toreturn = self.__dict__.copy()
for key in toreturn:
if key not in ('_data', '_sheets', '_types'):
del toreturn[key]
return toreturn
def __setstate__(self, arg):
self._data = arg['_data']
self._sheets = arg['_sheets']
self._types = arg['_types']
def __contains__(self, e):
'''__contains__(e) -> e in DataSet
Determind that weather the object is a sheet name inside.
'''
if isinstance(e, str):
return e in self._sheets
return any([e == data for data in self._data])
def __repr__(self):
if len(self._data) == 0:
return 'empty DataSet object'
reprs = ''
for i, data in enumerate(self._data):
reprs += 'sheet:' + self._sheets[i] + '\n'
reprs += '=' * (len(self._sheets[i]) + 6) + '\n'
reprs += data.__repr__() + '\n\n'
return reprs[:-2]
def __len__(self):
if len(self._data) == 1:
if hasattr(self._data[0], 'shape'):
return self._data[0].shape[0]
return len(self._data[0])
return len(self._data)
def __getitem__(self, key):
if len(self._data) == 1 and (key not in self._sheets):
return DataSet(self._data[0][key], self._sheets[0])
if isinstance(key, slice):
return self.__getslice__(key.start, key.stop)
def __getslice__(self, i, j):
return DataSet([_[i:j] for _ in self._data], self._sheets)
def __setitem__(self, key, val):
if len(self._data) == 1 and key not in self._sheets:
self._data[0].__setitem__(key, val)
return
if is_str(key):
if isinstance(val, DataSet):
for src, title in zip(val._data, val._sheets):
self._data.append(src)
self._types.append(type(src))
new_key = '%s_%s' % (key, title)
self._sheets.append(self._check_sheet_new_name(new_key))
return
if key not in self._sheets:
self._data.append(val)
self._types.append(type(val))
self._sheets.append(self._check_sheet_new_name(key))
return
if key in self._sheets:
key = self._sheets.index(key)
self._data[key] = val
self._types[key] = val
return
if isinstance(key, int):
assert abs(key) <= len(self._data), 'set index out of range'
self._data[key] = val
self._types[key] = type(val)
def __delslice__(self, start, stop):
if start not in self._sheets and stop not in self._sheets:
for data in self._data:
del data[start: stop]
return
start, stop = self._slice2int(start, stop)
del self._data[start: stop + 1]
def __delitem__(self, key):
if isinstance(key, slice):
self.__delslice__(key.start, key.stop)
elif key in self._sheets:
index = self._sheets.index(key)
del self._sheets[index], self._data[index], self._types[index]
elif isinstance(key, tuple):
for obj in key:
self.__delitem__(obj)
else:
for data in self._data:
data.__delitem__(key)
def __iter__(self):
if len(self._data) == 1:
for item in self._data[0]:
yield item
else:
for item in self._data:
yield item
def __reversed__(self):
if len(self._data) == 1:
self._data[0].reverse()
else:
self._data.reverse()
def _add(self, item, name):
if isinstance(item, DataSet):
name = '' if not name else name + '_'
new_sheets = [self._check_sheet_new_name(name + new) \
for new in item.sheets]
self._data.extend(item._data)
self._sheets.extend(new_sheets)
self._types.extend(item._types)
else:
self._data.append(item)
self._types.append(type(item))
self._sheets.append(self._check_sheet_new_name(name))
@timer
def add(self, items, names=None):
''' add a new sheet to the current dataset
Parameter
---------
item : object
the new sheet object
name : str or None ( default=None)
the new sheet name
Example
-------
>>> import DaPy as dp
>>> data2 = dp.DataSet([[1, 1, 1], [1, 1, 1]])
>>> data2
sheet:sheet0
============
Col_0 | Col_1 | Col_2
-------+-------+-------
1 | 1 | 1
1 | 1 | 1
>>> data.add(data2)
>>> data
sheet:sheet0
============
Col_0: <1, 2>
Col_1: <2, 3>
Col_2: <3, 4>
sheet:sheet0
============
Col_0 | Col_1 | Col_2
-------+-------+-------
1 | 1 | 1
1 | 1 | 1
'''
if not is_seq(items):
items = (items,)
if not is_seq(names):
names = (names,)
for item, name in zip(items, names):
self._add(item, name)
@timer
@operater
def apply(self, func, col=None, axis=0, *args, **kwrds):
pass
@timer
@operater
def append_row(self, item):
pass
@timer
@operater
def append_col(self, series, variable_name=None):
pass
@timer
@operater
def corr(self, method='pearson', col=None):
pass
@timer
@operater
def count(self, value, col=None, row=None):
pass
@timer
@operater
def copy(self):
pass
@timer
@operater
def count_values(self, col=None):
pass
@timer
@operater
def set_index(self, column):
pass
@timer
@operater
def get(self, key, default):
pass
def get_tables(self, cols=None):
key = self._check_sheet_index(cols)
title = [self._sheets[_] for _ in key]
src = [self._data[_] for _ in key]
return DataSet(src, title)
@timer
@operater
def get_best_features(self, method='variance', X=None, Y=None, top_k=1, inplace=False):
pass
@timer
@operater
def get_categories(self, cols, cut_points, group_name, boundary=(False, True), inplace=False):
pass
@timer
@operater
def get_date_label(self, cols, daytime=True,
weekend=True, season=True, inplace=False):
pass
@timer
@operater
def get_interactions(self, n_power=3, cols=None, inplace=False):
pass
@timer
@operater
def get_ranks(self, cols=None, duplicate='mean', inplace=False):
pass
@timer
@operater
def get_dummies(self, col=None, value=1, inplace=False):
pass
@timer
@operater
def get_nan_instrument(cols=None, inplace=False):
pass
@timer
@operater
def get_numeric_label(self, cols=None, inplace=False):
pass
@timer
@operater
def groupby(self, keys, func=None, apply_col=None, unapply_col=None):
pass
@timer
@operater
def insert_row(self, index, item):
pass
@timer
@operater
def insert_col(self, index, series, variable_name=None):
pass
@timer
@operater
def dropna(self, axis=0, how='any', inplace=False):
pass
@timer
@operater
def select(self, where, col=None, limit=1000):
pass
@timer
@operater
def pop(self, index=-1, aixs=0):
pass
@timer
@operater
def pop_row(self, index=-1):
pass
@timer
@operater
def pop_col(self, col='all'):
pass
@timer
@operater
def query(self, expression, col=None, limit=1000):
pass
@timer
@operater
def extend(self, other):
pass
@timer
@operater
def join(self, other):
pass
@timer
@operater
def normalized(self, process='NORMAL', col=None, **kwrds):
pass
@timer
@operater
def map(self, func, cols=None, inplace=False):
pass
@timer
@operater
def merge(self, other, self_key=0, other_key=0, keep_key=True, keep_same=True):
pass
@timer
@operater
def drop(self, index=-1, axis=0, inplace=False):
pass
@timer
@operater
def drop_row(self, index=-1, axis=0, inplace=False):
pass
@timer
@operater
def drop_col(self, index=-1, axis=0, inplace=False):
pass
@timer
@operater
def fillna(self, fill_with=None, col=None, method=None, limit=None):
pass
@timer
def read(self, addr, dtype='col', **kwrd):
'''This function could be used with loading data from a file and
transform it into one of DaPy data structure.
Parameters
----------
addr : str
the address of data file or a statement like:
"mysql://[username]:[password]@[server_ip]:[server_port]/[database_name]/[table1]/[table2]..."
to access a mysql database. Attention, if `table` keyword is missing
in this address, all records will be loaded.
ftype : str (default=None)
the file type of this address
`None` -> automtotally analysis the file type
"web" -> a website address, it will use requests.get to load the website
then use bs4.BeautifulSoup to find <table> tag in the file.
"html" -> a local html file
"db" -> SQLite3 database file
"sav" -> SPSS data file
"xls" -> Excel data file
"csv" -> Text file with ',' as delimeters
"txt" -> Text file with ' ' as delimeters
"pkl" -> Python pickle file
"sql" -> MySQL database commands file
"mysql" -> MySQL database Server
sheet_name : str (default=None)
the sheet name of new table.
miss_symbol : str or str in list (default=['?', '??', '', ' ', 'NA', 'None'])
the miss value symbol in this data file.
nan : value (default=nan)
the miss value symbol in your new data set.
first_line : int (default=1)
the first line which includes data values in this file.
title_line : int (default=0)
the line which includes your data's column names.
tip: if there is no title in your data, used -1 represented,
and, it will automatic create it.
sep : str (default=",")
the delimiter symbol inside.
dtypes : type name in str or dict of columns (default=None):
DaPy autometally transfers str source text into the most
suitable data type in efficiency. However, some of process costs
long time. For example, "2018-1-1" is a datetime label and
DaPy spends a long time time to transfer this label into datetime.
Thus, in some cases, you don't need it in datetime, so just set this column
type into "str" to save time. The supported data types are "int",
"float", "str", "datetime" and "bool".
use this keyword as following samples
>>> read("addr.csv", dtypes={'A_col': int, 'B_col': float})
>>> read("addr.csv", dtypes="float")
>>> read("addr.csv", dtypes=["float", "int"])
Examples
--------
>>> import DaPy as dp
>>> data = dp.read('your_data_file.csv')
>>> data.read('another_data_file.xlsx')
'''
nan = kwrd.get('nan', float('nan'))
sheet_name = kwrd.get('sheet_name', None)
miss_symbol = kwrd.get('miss_symbol', set(['?', '??', '', ' ', 'NA', 'None']))
fpath, fname, fbase, ftype = parse_addr(addr)
ftype = kwrd.get('ftype', ftype)
assert ftype in ('web', 'html', 'htm', 'db', 'sav', 'xls', 'xlsx', 'csv', 'txt', 'pkl', 'sql', 'mysql')
if ftype not in ('web', 'html', 'htm', 'mysql') and not isfile(addr):
raise IOError('can not find the target file or auto analysis data source type failed')
if sheet_name is None:
sheet_name = fbase
if ftype == 'db':
try:
import sqlite3 as sql3
except ImportError:
raise ImportError('DaPy uses "sqlite3" to access a database local file.')
with sql3.connect(addr) as conn:
cur = conn.cursor()
for sheet, name in parse_db(cur, dtype, nan):
self._add(sheet, name)
elif ftype == 'sav':
try:
import savReaderWriter
except ImportError:
raise ImportError('DaPy uses "savReaderWriter" to open a .sav file, '+\
'please try command: pip install savReaderWriter.')
with savReaderWriter.SavReader(addr) as reader:
self._add(parse_sav(reader, dtype, nan), sheet_name)
elif ftype == 'xls' or ftype == 'xlsx':
first_line = kwrd.get('first_line', 1)
title_line = kwrd.get('title_line', 0)
for sheet, name in parse_excel(dtype, addr, first_line, title_line, nan):
self._add(sheet, name)
elif ftype in ('txt', 'csv'):
kwrd['sep'] = kwrd.get('sep', {'csv':',', 'txt':'\t'}[ftype])
dtype_dic = {'COL': SeriesSet, 'SERIESSET': SeriesSet,
'MATRIX': Matrix, 'MAT': Matrix}
dtype = dtype_dic.get(dtype.upper(), SeriesSet)
self._add(dtype.from_file(addr, **kwrd), sheet_name)
elif ftype == 'pkl':
self._add(pickle.load(open(addr, 'rb')), sheet_name)
elif ftype in ('html', 'htm', 'web'):
if ftype == 'web':
try:
from requests import get
except ImportError:
raise ImportError('DaPy uses "reqeusts" to load a website.')
else:
text = get(addr).text
else:
with open(addr) as doc:
text = doc.read()
assert '<table' in text, 'there is no tag <table> in the html file.'
for sheet, name in parse_html(text, dtype, miss_symbol, nan, sheet_name):
self._add(sheet, name)
return self
elif ftype == 'mysql':
user, psd = fpath.split(':')
host, port = fbase.split(':')
try:
import pymysql as sql
except ImportError:
try:
import MySQLdb as sql
except ImportError:
raise ImportError('DaPy uses "pymysql" or "MySQLdb" libraries to access a database server.')
with sql.connect(host=host, port=int(port), user=user, passwd=psd, db=fname[0], charset='utf8') as cur:
for sheet, name in parse_mysql_server(cur, fname):
self._add(sheet, name)
elif ftype == 'sql':
with open(addr) as doc:
for sheet, name in parse_sql(doc, nan):
self._add(sheet, name)
return self
else:
raise ValueError('DaPy singly supports file types as'+\
'(xls, xlsx, csv, txt, pkl, db, sav, html, htm).')
@timer
@operater
def reshape(self, nshape):
pass
@timer
def reverse(self, axis='sheet'):
'''Reverse your data set or records.
Parameters
----------
axis : str (default='sheet')
settle down reverse sheets or records in each sheet.
Example
-------
>>> import DaPy as dp
>>> data = dp.DataSet([[1,2,3,4],
[2,3,4,5],
[3,4,5,6],
[4,5,6,7],
[5,6,7,8]])
>>> data.tocol()
>>> data.reverse()
'''
if axis.upper() == 'SHEET':
self._data.reverse()
self._sheets.reverse()
self._types.reverse()
return
if axis.upper() == 'RECORD':
for data in self._data:
if hasattr(data, 'reverse'):
data.reverse(axis)
return
raise AttributeError('axis should be "sheet" or "record"')
@timer
@operater
def replace(self, old, new, col=None, regex=False, sheet=None):
pass
@timer
@operater
def shuffle(self):
pass
@timer
@operater
def sort(self, *orders):
pass
@timer
def save(self, addr, **kwrds):
'''Save the DataSet to a file.
Parameters
----------
addr : str
the output file address.
encode : str (default='utf-8')
saving the file in such code type
ftype : str
the file type you want to save as. Use the file type in
your address as default. For example, 'data.save("test.csv")'
means save this object into .csv type. DaPy supports
following file types since V1.5.1:
.csv, .txt, .xls, .pkl, .db, .html
newline : str (default='\n')
use this simble to mark change line.
delimiter : str (default=',')
use this simble to seperate a records.
if_exists : str (default='fail')
when saving the data into a exist database file, how to face the
delimma that the sheet name has been existed in the database.
'fail' -> raise an error;
'replace' -> replace the exist table with current data;
'append' -> append these records to the exist sheet
'
'''
fpath, fname, fbase, ftype = parse_addr(addr)
encode = kwrds.get('encode', 'utf-8')
ftype = kwrds.get('ftype', ftype)
if ftype in ('csv', 'txt'):
newline = kwrds.get('newline', '\n')
delimiter = kwrds.get('delimiter', ',')
para = dict(mode='w', buffering=2048)
if PYTHON3:
para['encoding'] = encode
para['file'] = addr
else:
para['name'] = addr
for data, sheet in zip(self._data, self._sheets):
if data is None:
continue
if len(self._data) > 1:
addr = fpath + fbase + '_' + sheet + '.' + ftype
f = open(**para)
try:
write_txt(f, data, newline, delimiter)
finally:
f.close()
elif ftype in ('xls', 'xlsx'):
try:
import xlwt
except ImportError:
raise ImportError('DaPy uses xlwt library to save a `xls/xlsx` file.')
workbook = xlwt.Workbook(encoding=encode)
for sheet, data in zip(self._sheets, self._data):
if not data:
continue
worksheet = workbook.add_sheet(sheet)
write_xls(worksheet, data)
workbook.save(addr)
elif ftype == 'pkl':
pickle.dump(self, open(addr, 'wb'))
elif ftype == 'db':
import sqlite3 as sql
with sql.connect(addr) as conn:
for data, sheet in zip(self._data, self._sheets):
write_db(conn.cursor(), sheet, data, kwrds.get('if_exists', 'fail'), 'sqlite3')
elif ftype == 'html':
with open(addr, 'w') as f:
for data, sheet in zip(self._data, self._sheets):
if not data:
continue
f.write('<table border="1" class="%s">' % sheet)
write_html(f, data)
f.write('</table>')
elif ftype == 'sql':
with open(addr, 'w') as doc:
for name, sheet in zip(self._sheets, self._data):
write_sql(doc, sheet, name)
elif ftype == 'mysql':
try:
import pymysql as sql
except ImportError:
try:
import MySQLdb as sql
except ImportError:
raise ImportError('DaPy uses "pymysql" or "MySQLdb" libraries to access a database server.')
user, psd = fpath.split(':')
host, port = fbase.split(':')
with sql.connect(host=host, port=int(port), user=user, passwd=psd, db=fname[0], charset='utf8') as conn:
for data, sheet in zip(self._data, self._sheets):
write_db(conn, sheet, data, kwrds.get('if_exists', 'fail'), 'mysql')
else:
raise ValueError('unrecognized file type')
@timer
@operater
def todict(self):
pass
@timer
def tocol(self):
'''Transform all of the stored data structure to DaPy.SeriesSet
'''
for i, data in enumerate(self._data):
if isinstance(data, SeriesSet):
continue
try:
if hasattr(data, 'columns'):
if hasattr(data, 'miss_symbol'):
self._data[i] = SeriesSet(data, list(data.columns),
miss_value=data.miss_symbol)
else:
self._data[i] = SeriesSet(data, data.columns)
else:
self._data[i] = SeriesSet(data)
except Exception as e:
LogErr('sheet[%s] can not transform to SeriesSet, ' % self._sheets[i] +\
'because: %s' % e)
self._types[i] = SeriesSet
@timer
def tomat(self):
'''Transform all of the stored data structure to DaPy.Matrix
'''
for i, data in enumerate(self._data):
if isinstance(data, Matrix):
continue
try:
self._data[i] = Matrix(data)
except:
LogErr('sheet:%s can not transform to Matrix.'%self._sheets[i])
self._types[i] = Matrix
@timer
@operater
def tolist(self):
pass
@timer
@operater
def toarray(self):
pass
def show(self, max_lines=None, max_display=75, max_col_size=25, multi_line=True):
'''show(lines=None) -> None
See Also
--------
DaPy.SeriesSet.show
'''
for i, data in enumerate(self._data):
print('sheet:' + self._sheets[i])
print('=' * (len(self._sheets[i]) + 6))
if hasattr(data, 'show'):
data.show(max_lines, max_display, max_col_size, multi_line)
else:
pprint(data.__repr__())
if __name__ == '__main__':
from doctest import testmod
testmod()
================================================
FILE: DaPy/core/__init__.py
================================================
from .base import SeriesSet, Frame, Matrix, Series
from .base import is_seq, is_iter, is_math, is_value, is_str, argsort
from .base import range, filter, map, zip, xrange
from .base import LogInfo, LogWarn, LogErr
from .base import nan, inf
from .DataSet import DataSet, SHOW_LOG
================================================
FILE: DaPy/core/base/BaseSheet.py
================================================
from collections import Counter, defaultdict
from copy import copy
from itertools import chain, combinations, repeat
from operator import eq, ge, gt, itemgetter, le, lt
from random import shuffle as shuffles
from re import compile as re_compile
from re import findall, sub
from .constant import (DUPLICATE_KEEP, PYTHON2, PYTHON3, SHEET_DIM, STR_TYPE,
VALUE_TYPE)
from .constant import nan as NaN
from .DapyObject import Object
from .IndexArray import SortedIndex
from .Row import Row
from .Series import Series
from .utils import (argsort, auto_plus_one, auto_str2value, count_nan,
fast_str2value, hash_sort, is_dict, is_empty, is_iter,
is_math, is_seq, is_str, is_value, isnan, range, split,
str2date, strip, xrange, zip_longest, string_align)
from .utils.utils_str_patterns import *
from .utils.utils_join_table import inner_join, left_join, outer_join
from .utils.utils_regression import simple_linear_reg
LOCK_ERROR = 'sheet is locked by indexes, See drop_index()'
def where_by_index_combine(rows, symbols):
'''put all rows together'''
final_rows = set(rows[0])
for row, comb in zip(rows[1:], symbols):
if comb.strip() == 'and':
final_rows = final_rows & row
else:
final_rows = final_rows | row
return final_rows
class BaseSheet(Object):
'''The base sheet structure for user to handle 2D data structure
Attributes
----------
shape : namedtuple(Ln, Col)
a two dimensional span of this sheet.
nan : value (default=Nan)
a symbol represented miss value in current seriesset.
columns : str in list
names for each feature
data : dict / list in list
an object contains all the data by columns or row.
missing : int in list
number of missing value in each column.
indexes : SortedIndex in dict
a dict stored all indexes
'''
def __init__(self, obj=None, columns=None, nan=NaN):
Object.__init__(self)
self._missing = []
self.nan = nan
self._sorted_index = {}
if hasattr(obj, 'values') and not callable(obj.values):
# Pandas DataFrame -> Numpy array
columns = obj.columns
obj = obj.values
if isinstance(obj, BaseSheet):
if is_dict(self.data):
# initialize from a SeriesSet
self._init_col(obj, columns)
else:
# initialize from a DataFrame
self._init_frame(obj, columns)
elif obj is None or is_empty(obj):
# initialize an empty sheet
self._dim, self._columns = SHEET_DIM(0, 0), []
if columns is not None:
if is_str(columns):
columns = [columns, ]
for name in columns:
self._append_col([], name)
elif is_dict(obj):
# initialize from a dict
self._init_dict(obj, columns)
elif isinstance(obj, Series) or \
(is_seq(obj) and all(map(is_value, obj))):
# initialize from a single series
self._init_like_seq(obj, columns)
elif is_seq(obj) and all(map(is_iter, obj)):
# initialize from array-like object
self._init_like_table(obj, columns)
elif is_iter(obj):
# initialie from an iterator object
self._init_like_iter(obj, columns)
else:
raise TypeError("sheet don't support %s" % type(obj))
@property
def data(self):
'''self.data -> source container of the data'''
return self._data
@property
def shape(self):
'''self.shape -> numbers of rows and columns in tuple'''
return self._dim
@property
def columns(self):
'''self.columns -> copy of the columns in the sheet'''
return copy(self._columns)
@columns.setter
def columns(self, item):
'''self.columns = ['A', 'B'] -> setting columns of sheet'''
if self.shape.Col == 0 and item != []:
self._dim = SHEET_DIM(0, len(item))
self._missing = [0] * len(item)
old_col = item
old_col = self.columns
self._init_col_name(item)
for old, new in zip_longest(old_col, self.columns):
seq = self.data.get(old, Series())
if old in self._data:
del self.data[old]
self.data[new] = seq
@property
def nan(self):
'''self.nan -> return the symbol of missing value'''
return self._nan
@nan.setter
def nan(self, item):
'''self.nan = None -> change another missing value symbol'''
assert is_value(item), 'sheet.nan must be a value'
self._nan = item
self._init_nan_func()
for miss, seq in zip(self._missing, self.iter_values()):
if miss != 0:
for i, value in enumerate(seq):
if self._isnan(value):
seq[i] = item
@property
def locked(self):
'''self.is_mutable -> bool
check whether sheet is clock by sorted indexes or not'''
if not self._sorted_index:
return True
return False
def __repr__(self):
if self._dim.Ln > 10:
def write_line(title, blank):
item = self[title]
msg = ' ' * blank + title + ': <'
msg += ', '.join([str(value) for value in item[:5]])
msg += ', ... ,'
msg += ', '.join([str(value) for value in item[-5:]])
msg += '>\n'
return msg
elif self._dim.Ln != 0:
def write_line(title, blank):
item = self._data[title]
msg = ' ' * blank + title + ': <'
msg += ', '.join([str(value) for value in item])
msg += '>\n'
return msg
else:
return 'empty SeriesSet instant'
msg = ''
size = len(max(self._columns, key=len))
for title in self._columns:
msg += write_line(title, size - len(title))
return msg[:-1]
def __getattr__(self, name):
'''self.A -> return column A'''
if name in self._columns:
return self.__getitem__(name)
raise AttributeError("Sheet object has no attribute '%s'" % name)
def __len__(self):
'''len(sheet) -> number of rows'''
return self._dim.Ln
def __compare_value__(self, val, empty, symbol):
assert is_value(val), 'compare elements must be given a value'
for title, seq in self.iter_items():
empty._quickly_append_col(title, symbol(seq, val), 0)
return empty
def __contains__(self, cmp_):
'''3 in sheet -> True / False'''
if is_str(cmp_):
return cmp_ in self._data
if is_seq(cmp_):
if len(cmp_) == self._dim.Col:
for record in self:
if record == cmp_:
return True
elif len(cmp_) == self._dim.Ln:
for variable in self.iter_values():
if variable == cmp_:
return True
if is_value(cmp_):
for record in self:
for value in record:
if value == cmp_:
return True
return False
def __delitem__(self, key):
ok_types = tuple([STR_TYPE] + [int, list, tuple, slice])
assert isinstance(key, ok_types), 'not allowed type "%s"' % type(key)
if isinstance(key, int):
self.drop_row(key, True)
if is_str(key):
self.drop_col(key, True)
if isinstance(key, (list, tuple)):
int_keys = list(filter(is_math, key))
str_keys = list(filter(is_str, key))
if str_keys != []:
self.drop_col(str_keys, True)
if int_keys != []:
self.drop_row(int_keys, True)
if isinstance(key, slice):
self.__delslice__(key)
def __delslice__(self, key):
start, stop, axis = self._check_slice(key)
if axis == 1:
self.drop_col(self.columns[start, stop + 1], True)
elif axis == 0:
self.drop_col(range(start, stop), True)
def __getslice__(self, start, stop, step=1):
start, stop, axis = self._check_slice(slice(start, stop))
if axis == 1:
return self._getslice_col(start, stop)
if axis == 0:
return self._getslice_ln(start, stop, step)
raise TypeError('bad expression as [%s:%s]' % (start, stop))
def __getstate__(self):
instance = self.__dict__.copy()
instance['_dim'] = tuple(self._dim)
del instance['_isnan']
return instance
def __setstate__(self, read_dict):
'''load this object from a stream file'''
self._dim = SHEET_DIM(*read_dict['_dim'])
self._columns = read_dict['_columns']
self._missing = read_dict['_missing']
self._nan = read_dict['_nan']
self._sorted_index = read_dict['_sorted_index']
self._init_nan_func()
self._data = dict((key, Series(val)) for key, val in read_dict['_data'].items())
def __getitem__(self, interval):
if isinstance(interval, int):
return Row(self, interval)
if isinstance(interval, Series):
assert len(interval) == self.shape.Ln
return self._iloc([i for i, val in enumerate(interval) if val is True])
if isinstance(interval, (tuple, list)):
return self._getitem_by_tuple(interval, type(self)(nan=self._nan))
if isinstance(interval, slice):
start, stop = interval.start, interval.stop
return self.__getslice__(start, stop)
if is_str(interval):
return self._data[interval]
raise TypeError('Table index must be int, str and slice, ' +
'not %s' % str(type(interval)).split("'")[1])
def __iter__(self):
for i in xrange(self._dim.Ln):
yield Row(self, i)
def __reversed__(self):
for i in xrange(self._dim.Ln - 1, -1, -1):
yield Row(self, i)
def __setitem__(self, key, value):
'''sheet['Col'] = [1, 2, 3, 4] -> None'''
error = 'only support setting record(s) or column(s)'
if isinstance(key, int):
bias = key + 1 - self._dim.Ln
if bias <= 0:
self.__delitem__(key)
self._insert_row(key, value)
else:
shape = (bias - 1, self.shape.Col)
empty = type(self).make_table(shape, self.nan, self.nan)
empty.columns = self.columns
self._extend(empty)
self._append_row(value)
elif is_str(key):
if key in self._data:
pos = self._columns.index(key)
self.__delitem__(key)
self._insert_col(pos, value, key)
else:
self._append_col(value, key)
elif isinstance(key, slice):
start, stop, axis = self._check_slice(key)
if axis == 1:
self._setitem_slice_col(start, stop, value)
if axis == 0:
self._setitem_slice_row(start, stop, value)
elif isinstance(key, tuple):
args, int_args, slc_args, str_args = self._analyze_keywords(key)
if len(key) == 2 and len(int_args) == 1 and len(str_args) == 1:
ln, col = int_args[0], str_args[0]
self._setitem_cell(ln, col, value)
if len(args) == len(str_args):
if isinstance(value, BaseSheet):
assert value.shape[1] == len(args), 'values shape donot match keys shape'
for key, series in zip(str_args, value.iter_values()):
self[key] = series
else:
raise TypeError(error)
def _analyze_keywords(self, key):
args, int_args, slc_args, str_args = [], [], [], []
for arg in key:
if isinstance(arg, slice):
slc_args.append(arg)
for value in (arg.start, arg.stop):
if value is not None:
args.append(value)
elif isinstance(arg, int):
args.append(arg)
int_args.append(arg)
elif is_str(arg):
args.append(arg)
str_args.append(arg)
return args, int_args, slc_args, str_args
def _accumulate(self, func=None, cols=None, skipna=True):
for col in self._check_columns_index(cols):
self[col] = seq = self[col].accumulate(func, skipna)
index = self.columns.index(col)
if self._missing[index] != 0:
self._missing[index] = count_nan(self._isnan, seq)
return self
def _add_row(self, row):
# when user just input a single value as a row
if is_value(row):
assert self._dim.Col != 0, 'Adding a single value into an empty sheet is illegal.'
if self._isnan(row) is True:
self._missing = [_ + 1 for _ in self._missing]
self._dim = SHEET_DIM(self._dim.Ln + 1, self._dim.Col)
return [row] * self._dim.Col
# when user input a dict as a row
row = row._asdict() if hasattr(row, '_asdict') else row
if is_dict(row):
row, dic_row = [row.get(col, self.nan) for col in self.columns], row
for key, value in dic_row.items():
if key not in self._data:
row.append(value)
seq = Series(repeat(self.nan, self.shape.Ln))
self._quickly_append_col(key, seq, self.shape.Ln)
# in the normal way, we first calculate the bias of length
lenth_bias = len(row) - self._dim.Col
if lenth_bias > 0 and self.shape.Ln == 0:
for i in xrange(lenth_bias):
self._append_col(Series())
elif lenth_bias > 0:
for _ in xrange(lenth_bias):
series = Series(repeat(self._nan, self.shape.Ln))
self._quickly_append_col(None, series, self.shape.Ln)
miss, row = self._check_sequence(row, self.shape.Col)
self._dim = SHEET_DIM(self._dim.Ln + 1, max(self._dim.Col, len(row)))
if miss != 0:
for i, value in enumerate(row):
if self._isnan(value):
self._missing[i] += 1
return row
def _append_row(self, row):
row = self._add_row(row)
for val, col, seq in zip(row, self.columns, self.iter_values()):
seq.append(val)
if col in self._sorted_index:
self._sorted_index[col].append(val)
def _append_col(self, series, variable_name=None):
miss, series = self._check_sequence(series, self._dim.Ln)
size = len(series)
if size > self._dim.Ln:
bias = size - self._dim.Ln
for i, title in enumerate(self._columns):
self._missing[i] += bias
self._data[title].extend([self._nan] * bias)
self._quickly_append_col(variable_name, series, miss)
def _map(self, func, cols):
err = 'Your are operating columns which are Index. '
err += 'Please delete that Index at first!'
assert all(map(lambda x: x not in self._sorted_index, cols)), err
for name in self._check_columns_index(cols):
self.data[name] = seq = self.data[name].map(func)
ind = self.columns.index(seq)
self._missing[ind] = count_nan(self._isnan, seq)
return self
def _apply(self, func, col, *args, **kwrds):
if axis == 0:
new_col = self._check_col_new_name(None)
subset = self[cols]
try:
func(subset[0].tolist())
subset = subset.iter_values()
except Exception as e:
pass
new_seq = (func(row) for row in subset)
self._append_col(new_seq, new_col)
return self
def _arrange_by_index(self, self_new_index=None):
for title, sequence in self._data.items():
self._data[title] = sequence[self_new_index]
return self
def _check_mixture_tuple(self, key):
'''don't let user use sheet[:, 0] syntax'''
left, right = key
if left.start is None and left.stop is None:
if isinstance(right, slice):
rstart, rstop = right.start, right.stop
maybe = (self.columns[rstart], self.columns[rstop])
maybe += (rstart, rstop)
raise SyntaxError('do you mean sheet' +
'["%s":"%s"] or sheet[%s:%s]?' % maybe)
if isinstance(right, int):
raise SyntaxError(
'do you mean sheet ' +
'["%s"] or sheet[%s]' % (self.columns[right], right))
def _check_sequence(self, series, size):
'''check the shape of the sequence and fill nan if not long enough
if sequence is record, size = self.shape.Ln;
else size = self.shape.Col
'''
if is_value(series):
return 0, Series(repeat(series, size))
if is_str(series) or not is_iter(series):
series = [series]
series = Series(series)
if len(series) < size:
series = chain(series, [self._nan] * (size - len(series)))
series = Series(series)
return count_nan(self._isnan, series), series
def _check_col_new_name(self, new_name):
if new_name is None:
return self._check_col_new_name('C_%d' % len(self._columns))
new_name = PATTERN_CHANGE_LINE.sub('', str(new_name))
if is_str(new_name) and new_name not in self._columns:
return new_name
return auto_plus_one(self._columns, new_name)
def _check_slice(self, slc):
start, stop = slc.start, slc.stop
types_1 = is_str(start) == is_str(stop)
types_2 = is_math(start) == is_math(stop)
types_3 = None in (start, stop)
error = 'only support operate row or column at each time'
assert types_1 or types_2 or types_3, error
if isinstance(start, int) or isinstance(stop, int):
start, stop = self._check_slice_row(start, stop)
return start, stop, 0
# is_str(start) or is_str(stop):
start, stop = self._check_slice_col(start, stop)
return start, stop, 1
def _check_slice_row(self, start, stop):
lenth = self.shape.Ln
if start is None:
start = 0
elif start < 0:
start += lenth
elif start > lenth:
start = lenth
if stop is None or stop > lenth:
stop = lenth
elif stop < 0:
stop += lenth
error = 'Index [%s:%s] out of range % s' % (start, stop, lenth)
assert 0 <= start <= lenth and 0 <= stop <= lenth, error
return start, stop
def _check_slice_col(self, start, stop):
if start in self._columns:
start = self._columns.index(start)
elif start is None:
start = 0
else:
raise ValueError('`%s` is not a title in this sheet' % start)
if stop in self._columns:
stop = self._columns.index(stop)
elif stop is None:
stop = self._dim.Col - 1
else:
raise ValueError('`%s` is not a title in this sheet' % stop)
return start, stop
def _check_operation_key(self, keys):
'''transfer the string key name into itemgetter object'''
return itemgetter(*tuple(map(self.columns.index, keys)))
def _check_columns_index(self, col):
if col is None:
return tuple(self._columns)
if is_str(col):
error = '%s is not a title in current dataset' % col
assert col in self._columns, error
return (col,)
if isinstance(col, int):
if col < 0:
col += self.shape.Col
assert col < self.shape.Col, 'title index is out of range'
return (self._columns[col],)
if is_seq(col):
return tuple(self._check_columns_index(_)[0] for _ in col)
if isinstance(col, slice):
start, stop, axis = self._check_slice(col)
assert axis == 1, "don't put a row index in here"
return self.columns[start, stop]
def _check_rows_index(self, row):
assert is_str(row) is False, 'row index must not be a str'
if row is None:
return range(self.shape.Ln)
if isinstance(row, int):
if row < 0:
row += self.shape.Ln
assert row < self.shape.Ln, 'row index is out of range'
return (row,)
if is_seq(row):
return tuple(self._check_rows_index(_)[0] for _ in row)
#if isinstance(row, slice):
start, stop, axis = self._check_slice(row)
assert axis == 0, "don't put a column index in here"
return range(start, stop)
def _diff(self, lag=1, cols=None):
cols = self._check_columns_index(cols)
for col in cols:
seq = self[col].diff(lag)
seq.insert(0, self.nan)
self[col] = seq
return self
def _drop_col(self, index):
pop_name = list(set(self._check_columns_index(index)))
line, col = self.shape
for title in pop_name:
pos = self._columns.index(title)
del self._data[title], self._missing[pos], self._columns[pos]
if title in self._sorted_index:
del self._sorted_index[title]
col -= len(pop_name)
if col == 0:
line = 0
self._dim = SHEET_DIM(line, col)
return self
def _drop_row(self, index):
assert self.locked, LOCK_ERROR
index = self._check_rows_index(index)
for i, seq in enumerate(self.iter_values()):
del seq[index]
self._missing[i] = count_nan(self._isnan, seq)
self._dim = SHEET_DIM(self._dim.Ln - len(index), self._dim.Col)
return self
def _extend(self, item):
other_miss = item.missing
for title, sequence in item.iter_items():
miss = other_miss[title]
if title not in self.columns:
self._columns.append(self._check_col_new_name(title))
self._missing.append(self._dim.Ln + miss)
seq = Series(repeat(self._nan, self._dim.Ln))
else:
self._missing[self.columns.index(title)] += miss
seq = self.data[title]
seq.extend(sequence)
self._data[title] = seq
self._dim = SHEET_DIM(self.shape.Ln + item.shape.Ln, len(self._columns))
for i, sequence in enumerate(self.values()):
if len(sequence) != self._dim.Ln:
add_miss_size = self._dim.Ln - len(sequence)
sequence.extend(repeat(self.nan, add_miss_size))
self._missing[i] += add_miss_size
return self
def _fillna(self, fill_with=None, col=None, method=None, limit=None):
cols = self._check_columns_index(col)
isnan_fun = self._isnan
if limit is None:
limit = self.shape.Ln
assert limit >= 1, 'fill with at least 1 missing value, not limit=%s' % limit
assert method in ('linear', 'polynomial', 'quadratic', None, 'mean', 'mode')
if method is None:
self._fillna_value(fill_with, cols, isnan_fun, limit)
elif method == 'mean':
for col in cols:
mean = Series(_ for _ in self[col] if not isnan_fun(_)).mean()
self._fillna_value(mean, [col], isnan_fun, limit)
elif method == 'mode':
for col in cols:
seq = Series(_ for _ in self[col] if not isnan_fun(_))
mode = Counter(seq).most_common()[0][0]
self._fillna_value(mode, [col], isnan_fun, limit)
else:
func = simple_linear_reg
self._fillna_simple_function(cols, isnan_fun, limit, func)
return self
def _fillna_value(self, fill_with, col, _isnan, all_limit):
err = '`fill_with` must be a value'
assert isinstance(fill_with, (dict,) + VALUE_TYPE), err
if isinstance(fill_with, dict) is False:
fill_with = dict(zip(col, repeat(fill_with)))
for key, fill_val in fill_with.items():
limit = all_limit
key_index = self.columns.index(key)
if key in col and self._missing[key_index] != 0:
sequence = self[key]
for i, val in enumerate(sequence):
if _isnan(val) is True:
sequence[i] = fill_val
self._missing[key_index] -= 1
limit -= 1
if limit == 0:
break
def _fillna_simple_function(self, col, _isnan, all_limit, func):
'''establish a linear model to predict the missing value
This function will predict the missing value with a linear model,
which is established by the arounding records.
'''
for key in col:
limit = all_limit
key_index = self.columns.index(key)
if self._missing[key_index] == 0:
continue
seq = self._data[key]
for i, value in enumerate(seq):
if _isnan(value) is False and _isnan(seq[i + 1]) is False:
break
if i != 0:
xlist = []
for value in seq[i:2 * i + 1]:
if _isnan(value) is True:
break
xlist.append(value)
slope, constant = func(xlist, range(i, 2 * i + 1))
for ind in xrange(0, i):
seq[ind] = slope * ind + constant
self._missing[key_index] -= 1
limit -= 1
if limit == 0:
break
start = None
for stop, value in enumerate(seq):
if limit == 0:
break
if _isnan(value) is True:
if start is None:
start = stop
elif start is not None:
empty_length = stop - start
back = max(start - empty_length, 0)
fore = min(stop + empty_length, len(seq))
left_length = start - back + 2
ylist = seq[back:start] + seq[stop:fore]
xlist = range(left_length) +\
range(left_length + empty_length - 1,
len(ylist) + empty_length + 1)
slope, constant = func(*zip(*[
(_x, _y) for _x, _y in zip(xlist, ylist) \
if _isnan(_y) is False]))
left_length += 2
for ind, _ in enumerate(xrange(left_length, left_length + empty_length), start):
seq[ind] = slope * _ + constant
self._missing[key_index] -= 1
if limit == 0:
break
start = None
def _flatten(self, axis):
assert axis in (0, 1), 'axis must be 1 or 0'
if axis == 0:
return chain.from_iterable(self.iter_rows())
return chain.from_iterable(self.iter_values())
def _getitem_by_tuple_subcol(self, key, subset):
'''given columns, get subset'''
for arg in key:
if is_str(arg):
seq = self.data[arg]
miss = self._missing[self._columns.index(arg)]
subset._quickly_append_col(arg, seq, miss)
elif isinstance(arg, slice):
start, stop = self._check_slice_col(arg.start, arg.stop)
for col in self._columns[start:stop + 1]:
miss = self._missing[self._columns.index(col)]
seq = self.data[col]
subset._quickly_append_col(col, seq, miss)
else:
raise TypeError('bad statement as sheet[%s]' % col)
return subset
def _getitem_by_tuple_subrow(self, int_args, slc_args, subset):
'''given rows, get subset'''
subset = self._iloc(subset, int_args)
for row in slc_args:
start, stop = self._check_slice_row(row.start, row.stop)
subset.extend(self._getslice_ln(start, stop, 1))
return subset
def _getitem_by_tuple(self, key, subset):
'''given columns or rows, get subset'''
if is_seq(key) and len(key) == 2 and isinstance(key[0], slice):
self._check_mixture_tuple(key)
args, int_args, slc_args = self._analyze_keywords(key)[:3]
subcol = all(map(is_str, args))
subrow = all(map(is_math, args))
err = "don't get subset with columns and rows at the " +\
"same time. Use: sheet['A':'B'][3:10] or sheet[3:10]['A':'B']"
assert subcol or subrow, err
if subcol is True:
return self._getitem_by_tuple_subcol(key, subset)
return self._getitem_by_tuple_subrow(int_args, slc_args, subset)
def _group_index_by_column_value(self, columns, engine=list):
subset = defaultdict(engine)
for i, row in enumerate(zip(*(self._data[col] for col in columns))):
subset[row].append(i)
return subset
def _getslice_col(self, i, j):
subset = type(self)(nan=self.nan)
for ind, col in enumerate(self._columns[i: j + 1], i):
subset._quickly_append_col(col, self._data[col], self._missing[ind])
return subset
def _getslice_ln(self, i, j, k):
subset = type(self)(nan=self.nan)
for miss, col in zip(self._missing, self._columns):
seq = self._data[col][i:j:k]
if miss != 0:
miss = count_nan(self._isnan, seq)
subset._quickly_append_col(col, seq, miss)
return subset
def _get(self, key, default=None):
if is_str(key) and key in self._columns:
return self[key]
if isinstance(key, int):
if key < 0:
key += self.shape.Ln
if key < self.shape.Ln:
return self[key]
return default
def _get_best_features(self, method, X, Y, top_k):
cols = self._check_columns_index(X)
assert method in ('variance', 'anova')
if isinstance(top_k, float):
top_k = int(top_k * self.shape.Col)
assert isinstance(top_k, int) and top_k >= 0, '`top_k` must be greater than 0'
if method == 'variance':
feature_importance = [(self[_].cv(), _) for _ in cols]
if method == 'anova':
assert Y in self.data, 'Y must be a column in this dataset'
from DaPy.methods import ANOVA
feature_importance = [(ANOVA(self[_, Y], Y).F, _) for _ in cols]
feature_importance = filter(lambda val: not self._isnan(val[0]), feature_importance)
feature_importance = sorted(feature_importance, reverse=True)[:top_k]
return self[tuple(_[1] for _ in feature_importance)]
def _get_categories(self, cols, cut_points, group_name, boundary):
from DaPy.operation import get_categories
assert any(map(self._isnan, group_name)), '%s can not be a group name' % self.nan
cols = self._check_columns_index(cols)
for i, (key, seq) in enumerate(self.items):
if key in cols:
cate = get_categories(seq, cut_points, group_name, boundary)
self._quickly_append_col('%s_category' % col, cate, self._missing[i])
return self
def _get_date_label(self, date, col, day, weekend, season):
if day is True:
new = self._check_col_new_name('%s_daytime' % col)
self[new] = date['hour']
self.update('%s in set([23] + range(7))' % new, {new: 'latenight'})
self.update('%s in set(range(7, 11))' % new, {new: 'morning'})
self.update('%s in set(range(11, 14))' % new, {new: 'noon'})
self.update('%s in set(range(14, 18))' % new, {new: 'afternoon'})
self.update('%s in set(range(18, 23))' % new, {new: 'night'})
if weekend is True:
new = self._check_col_new_name('%s_weekend' % col)
self[new] = date['week']
self.replace([0, 1, 2, 3, 4, 5, 6],
[1, 0, 0, 0, 0, 0, 1],
col=new)
if season is True:
new = self._check_col_new_name('%s_season' % col)
self[new] = date['month']
self.update('%s in set([3, 4, 5])' % new, {new: 'spring'})
self.update('%s in set([6, 7, 8])' % new, {new: 'summer'})
self.update('%s in set([9, 10, 11])' % new, {new: 'autumn'})
self.update('%s in set([12, 1, 2])' % new, {new: 'winter'})
def _get_dummies(self, cols, value=1):
from DaPy import get_dummies
cols = self._check_columns_index(cols)
for title in cols:
dummies = get_dummies(self._data[title], value, 'set')
dummies.columns = [title + '=' + _ for _ in dummies.columns]
self.join(dummies, inplace=True)
return self
def _get_interactions(self, new_features, n_power, cols):
def combinations(arr, n):
if n == 1:
return [(val,) for val in arr]
tup = set()
for exist in combinations(arr, n - 1):
for val in arr:
tup.add(tuple(sorted(exist + (val,))))
return tup
def create_title(title, count):
n_title = count[title]
if n_title != 1:
return '%s^%d' % (title, n_title)
return title
cols = self._check_columns_index(cols)
assert isinstance(n_power, int) and n_power > 1, '`n_power` must be an integer and greater than 1'
pairs = combinations(cols, n_power)
for combine in pairs:
count = Counter(combine)
title, seq = create_title(combine[0], count), self[combine[0]]
miss_values = 0
for col in combine[1:]:
seq *= self._data[col]
miss_values += self[col]
if col not in title:
title += '*' + create_title(col, count)
if miss_values > 0:
miss_values = count_nan(self._isnan, seq)
new_features._quickly_append_col(title, seq, miss_values)
return new_features
def _get_nan_instrument(self, instruments, cols):
check_nan = self._isnan
for col in self._check_columns_index(cols):
seq = self[col].apply(lambda val: 1 if check_nan(val) else 0)
instruments._quickly_append_col(col + '=NaN', seq, 0, pos=None)
return instruments
def _get_ranks(self, ranks, cols, duplicate):
from DaPy.operation import get_ranks
cols = self._check_columns_index(cols)
for col in cols:
rank_col = get_ranks(self[col], duplicate)
ranks._quickly_append_col(rank_col, '%s_rank' % col, 0)
return ranks
def _get_numeric_label(self, to_return, cols):
for col in self._check_columns_index(cols):
labels = {}
seq = self[col].apply(lambda val: labels.setdefault(val, len(labels)))
to_return[col] = seq
return labels
def _init_col_name(self, columns):
if is_str(columns) and self._dim.Col == 1:
self._columns = [columns, ]
elif is_str(columns) and self._dim.Col != 1:
self._columns = [columns + '_%d' % i for i in range(self._dim.Col)]
elif columns is None or str(columns).strip() == '':
self._columns = ['C_%d' % i for i in xrange(self._dim.Col)]
elif is_iter(columns) is True:
self._columns, columns = [], list(columns)
bias = self._dim.Col - len(columns)
columns.extend(['C_%d' % i for i in range(bias)])
for col in columns[:self._dim.Col]:
self._columns.append(self._check_col_new_name(col))
for _ in xrange(self._dim.Col - len(self._columns)):
self._columns.append(self._check_col_new_name(None))
else:
raise TypeError('column names should be stored in a iterable')
def _init_nan_func(self):
if isnan(self._nan) is True:
self._isnan = isnan
else:
self._isnan = lambda val: val == self._nan
def _init_col(self, series, columns):
'''initialzie from a SeriesSet
Notes
-----
1. This function has been added into unit test.
'''
if columns is None:
columns = series.columns
self._dim = copy(series.shape)
self._init_col_name(columns)
for col, seq in zip(self.columns, series.values()):
self._data[col] = copy(seq)
self._missing = list(series.missing)
self.nan = series.nan
def _init_dict(self, series, columns):
'''initialize from a dict object
Notes
-----
1. This function has been added into unit test.
'''
if columns is None:
columns = list(series.keys())
for key, value in series.items():
if is_value(value) is True:
series[key] = [value]
max_ln = max(map(len, series.values()))
self._dim = SHEET_DIM(max_ln, len(series))
self._init_col_name(columns)
for col in self.columns:
miss, sequence = self._check_sequence(series[col], self._dim.Ln)
self._missing.append(miss)
self._data[col] = sequence
def _init_frame(self, series, columns):
'''initialize from a Frame
Notes
-----
1. This function has been added into unit test.
'''
if columns is None:
columns = series.columns
self._dim = copy(series.shape)
self._missing = list(series.missing)
self._init_col_name(columns)
for sequence, title in zip(zip(*series), self._columns):
self._data[title] = Series(sequence)
self.nan = series.nan
def _init_like_seq(self, series, columns):
'''initialize from a single sequence
Notes
-----
1. This function has been added into unit test.
'''
self._dim = SHEET_DIM(len(series), 1)
self._init_col_name(columns)
miss, series = self._check_sequence(series, self._dim.Ln)
self._missing = [miss, ]
self._data[self._columns[0]] = series
def _init_like_table(self, series, columns):
'''initialize from an array-like object
Notes
-----
1. This function has been added into unit test.
'''
lenth_col = len(max(series, key=len))
self._dim = SHEET_DIM(len(series), lenth_col)
self._init_col_name(columns)
self._missing = [0] * self._dim.Col
for j, sequence in enumerate(zip_longest(fillvalue=self.nan, *series)):
miss, series = self._check_sequence(sequence, self._dim.Ln)
self._missing[j] += miss
self._data[self._columns[j]] = series
def _init_like_iter(self, series, columns):
'''initialize from an iterator'''
data_columns = []
self._missing = []
for i, row in enumerate(series):
bias = len(row) - len(data_columns)
self._missing.extend(repeat(0, bias))
more_col = [Series(repeat(self.nan, i)) for _ in xrange(bias)]
data_columns.extend(more_col)
for j, (ser, val) in enumerate(zip(data_columns, row)):
ser.append(val)
if self._isnan(val):
self._missing[j] += 1
self._dim = SHEET_DIM(len(data_columns[0]), len(data_columns))
self._init_col_name(columns)
self._data = dict(zip(self.columns, data_columns))
def _iloc(self, subset, indexs):
if is_seq(indexs) is False:
indexs = tuple(indexs)
for miss, (key, sequence) in zip(self._missing, self.iter_items()):
seq = sequence[indexs]
if isinstance(seq, Series) is False:
seq = Series([seq])
if miss != 0:
miss = count_nan(self._isnan, seq)
subset._quickly_append_col(key, seq, miss)
return subset
def _iter_groupby(self, keys, func=None, apply_col=None):
def operate_subset(subset, key):
ret = subset.apply(func, cols=apply_col, axis=1)
for key_value, key_name in zip(key, keys):
if key_name not in ret.columns:
pos = self.columns.index(key_name)
ret.insert_col(pos, key_value, key_name)
return ret[0]
keys = self._check_columns_index(keys)
assert keys, 'must give at least 1 key column to group by'
if len(keys) == 1 and keys[0] in self._sorted_index:
subsets = {}
index = self._sorted_index[keys[0]]
for group_value in set(self._data[keys[0]]):
subsets[(group_value,)] = index.equal(group_value)
else:
subsets = self._group_index_by_column_value(keys)
if func is not None:
apply_col = self._check_columns_index(apply_col)
for keyword, rows in subsets.items():
subset = self.iloc(rows)
yield operate_subset(subset, keyword)
else:
for keyword, rows in subsets.items():
yield keyword, self.iloc(rows)
def _insert_row(self, index, new_row):
new_row = self._add_row(new_row)
for value, seq in zip(new_row, self.iter_values()):
seq.insert(index, value)
def _insert_col(self, index, new_series, new_name):
miss, new_series = self._check_sequence(new_series, self._dim.Ln)
empty_size = len(new_series) - self.shape.Ln
if empty_size > 0:
for i, sequence in enumerate(self.iter_values()):
sequence.extend(repeat(self.nan, empty_size))
self._missing[i] += empty_size
self._quickly_append_col(new_name, new_series, miss, index)
def _join(self, other):
assert is_value(other) is False, 'cannot join a value to the dataset.'
error = "can't join empty object, given %s" % other
assert (hasattr(other, 'shape') and other.shape[1] != 0) or other, error
bias = other.shape.Ln - self.shape.Ln
if bias > 0:
for i, title in enumerate(self._columns):
self._data[title].extend(repeat(self.nan, bias))
self._missing[i] += bias
for (title, seq), miss in zip(other.iter_items(), other._missing):
if len(seq) < self.shape.Ln or miss != 0:
miss, seq = self._check_sequence(seq, self._dim.Ln)
self._quickly_append_col(title, seq, miss)
return self
def _match_column_from_str(self, statement):
sorted_column = sorted(self.columns, key=len, reverse=True)
pattern = '|'.join([PATTERN_COLUMN % x for x in sorted_column])
useful_col = [col.strip() for col in findall(pattern, statement)]
return [col.replace('(', '').replace(')', '') for col in useful_col]
@classmethod
def make_table(cls, shape, fill_with=None, nan=NaN):
table = cls(nan=nan)
shape = table._analyze_keywords(shape)[1]
assert len(shape) == 2, 'shape of Table object must be 2 dimensions with integers'
ln, col = shape
for col in range(col):
table.append_col(Series(repeat(fill_with, ln)))
return table
def _normalized(self, process, cols):
assert process in ('NORMAL', 'STANDAR', 'LOG', 'BOX-COX')
cols = self._check_columns_index(cols)
from DaPy import describe, log, boxcox
for title in cols:
if process in ('NORMAL', 'STANDAR'):
statis = describe(self._data[title])
if None in statis:
continue
if process == 'NORMAL':
center = float(statis.Min)
var = float(statis.Range)
elif process == 'STANDAR':
center = float(statis.Mean)
var = float(statis.Sn)
assert var != 0, 'range or std of `%s` is 0 ' % title
self._map(
lambda val: (val - center) / var,
cols=title)
elif process == 'BOX-COX':
func = lambda val: boxcox(
val,
kwrds.get('lamda', 1),
kwrds.get('a', 0),
kwrds.get('k', 1))
self._map(func, col=title)
elif process == 'LOG':
self._map(
lambda val: log(val, kwrds.get('base', 2.71828183)),
cols=title)
return self
def _pop_row(self, pop_data, index=-1):
assert self.locked, LOCK_ERROR
pop_index = self._check_rows_index(index)
for i, (title, seq) in enumerate(self.iter_items()):
pop_data[title] = seq.pop(pop_index)
if self._missing[i] != 0:
self._missing[i] -= pop_data[title].count(self._nan)
self._dim = SHEET_DIM(self._dim.Ln - len(index), self._dim.Col)
return pop_data
def _pop_col(self, pop_data, col):
pop_name = self._check_columns_index(col)
for title in pop_name:
pos = self._columns.index(title)
pop_data._quickly_append_col(
col=self._columns.pop(pos),
seq=self._data.pop(title),
miss=self._missing.pop(pos)
)
if title in self._sorted_index:
pop_ind = self._sorted_index.pop(title)
pop_data._sorted_index[title] = pop_ind
self._dim = SHEET_DIM(self._dim.Ln, self._dim.Col - len(pop_name))
return pop_data
def _query(self, expression, col, limit):
assert is_str(expression), '`expression` should be a python statement'
select_col = self._check_columns_index(col)
useful_col = self._match_column_from_str(expression)
assert useful_col, "can't match any column from `expression`"
if limit is None:
limit = self.shape.Ln
if all([col in self._sorted_index for col in useful_col]) is False:
subset = self[useful_col]
where = subset._trans_where(expression, axis=0)
return tuple(subset._where_by_rows(where, limit)), select_col
return sorted(self._where_by_index(expression))[:limit], select_col
def _quickly_append_col(self, col, seq, miss, pos=None):
'''append a new column to the sheet without checking'''
col = self._check_col_new_name(col)
if pos is None:
pos = len(self.columns)
self._data[col] = seq
self._columns.insert(pos, col)
self._missing.insert(pos, miss)
self._dim = SHEET_DIM(len(seq), self._dim.Col + 1)
return self
def _replace(self, old, new, col, regex):
col = self._check_columns_index(col)
assert self._isnan(new) is False, 'transfer value cannot be NaN'
if regex is True:
assert is_str(old), '`where` must be str when regex=True'
condition = re_compile(old)
where = lambda val: condition.sub(new, val)
if is_value(old) and regex is False:
list_old = [old]
where = lambda val: new if old == val else val
if is_seq(old) and is_seq(new):
assert len(old) == len(new), 'length of keys != length of value'
list_old = old
condition = dict(zip(old, new))
where = lambda val: condition.get(val, val)
for column in col:
sequence = self.data[column]
if column in self._sorted_index and regex is False:
# speed up process with Index
for old_ in list_old:
to_replace = where(old_)
for i in self._sorted_index.equal(old_):
sequence[i] = to_replace
else:
# iter each row and compare
for i, val in enumerate(sequence):
sequence[i] = where(val)
return self
def _reverse(self, axis=0):
assert axis in (0, 1)
if axis == 1:
self._columns.reverse()
self._missing.reverse()
else:
for sequence in self._data.values():
sequence.reverse()
return self
def _setitem_slice_row(self, start, stop, value):
nan_num = 1 if self._isnan(value) else 0
for i, arr in enumerate(self.iter_values()):
block = arr[start:stop]
lenth = len(block)
arr[start:stop] = repeat(value, lenth)
self._missing[i] -= count_nan(self._isnan, block)
self._missing[i] += nan_num * lenth
def _setitem_slice_col(self, start, stop, value):
columns = self.columns[start:stop]
err = "number of columns don't match number of given data"
assert len(columns) == len(value), err
for i, column, seq in zip(range(start, stop), columns, value):
miss, seq = self._check_sequence(seq, self.shape.Ln)
bias = len(seq) - self.shape.Ln
if bias > 0:
self._dim = SHEET_DIM(self.shape.Ln + bias,
self.shape.Col)
for j, (col, src_seq) in enumerate(self.iter_items()):
if col not in columns:
src_seq.extend(repeat(self.nan, bias))
self._missing[j] += bias
self._data[column] = seq
self._missing[i] = miss
def _setitem_cell(self, ln, col, val):
if col not in self._data:
self._append_col(Series(), col)
if ln + 1 > self.shape.Ln:
dtype = type(self)
shape = (ln + 1, self.shape.Col)
empty = dtype.make_table(shape, self.nan, self.nan)
empty.columns = self.columns
self._extend(empty)
arr = self._data[col]
if self._isnan(arr[ln]):
self._missing[self.columns.index(col)] -= 1
if self._isnan(val):
self._missing[self.columns.index(col)] += 1
arr[ln] = val
def _shuffle(self):
new_index = range(self._dim.Ln)
shuffles(new_index)
return self._arrange_by_index(new_index)
def _show(self, col_size, rows, omit_line, max_len, omit):
frame = u''
for i, row in enumerate(rows):
if i == omit_line:
frame += ('.. Omit %d Ln ..' % omit).center(max_len) + '\n'
line = ''
for size, value in zip(col_size, row):
line += ' ' + string_align(value, size) + ' |'
frame += line[:-1] + '\n'
if i == 0:
frame += '+'.join(['-' * (_ + 2) for _ in col_size]) + '\n'
return frame
def _sort(self, subset, *orderby):
err = "orderby must be a sequence of conditions like ('A_col', 'DESC')"
assert all(map(lambda x: (is_seq(x) and len(x) == 2)
or is_str(x), orderby)), err
symbols = ['ASC' if is_str(_) else str(_[1]) for _ in orderby]
if is_str(orderby[0]):
orderby = [(_,) for _ in orderby]
keys = self._check_columns_index([_[0] for _ in orderby])
if not (len(symbols) == 1 and isinstance(self._data, dict)):
columns = tuple(map(self.columns.index, keys))
temp = hash_sort(self.iter_rows(), *zip(columns, symbols))
return type(self)(temp, self.columns)
reverse = False
if symbols[0] == 'DESC':
reverse = True
new_index = argsort(list(self.data[keys[0]]), reverse=reverse)
for i, (key, seq) in enumerate(self.iter_items()):
subset._quickly_append_col(key,
seq[new_index],
self._missing[i])
return subset
def _trans_where(self, where, axis=0):
assert axis in (1, 0), 'axis 1 for value, 0 for sequence'
if axis == 0:
if where is None:
return lambda x: True
where = ' ' + where + ' '
last_length = len(where)
for i in argsort(self._columns, key=len, reverse=True):
where = sub(self._columns[i], '___x___[%d]' % i, where)
if last_length == len(where):
where = "'''%s'''" % where.strip()
where = 'lambda ___x___: ' + where
if axis == 1:
opeartes = {' and': 4, ' or': 3}
for opearte, bias in opeartes.items():
counts = where.count(opearte)
index = 0
for i in xrange(counts):
index = where.index(opearte, index) + bias
where = where[: index] + ' ___x___' + where[index:]
index += bias
where = 'lambda ___x___: ___x___ ' + where
return eval(where)
def _update(self, where, **set_values):
if callable(where) is False:
where = self._trans_where(where, axis=0)
assert set_values, '`set_value` are empty'
for key, exp in set_values.items():
if callable(exp) is False:
set_values[key] = self._trans_where(str(exp), axis=0)
for index in self._where_by_rows(where, limit=self.shape.Ln):
row = Row(self, index)
for key, value in set_values.items():
row[key] = value(row)
def _where_by_index_bigcombine(self, combines, string):
'''process statement like: (A > 1 and B < 2) and (C < 2)'''
string = PATTERN_RECOMBINE.findall(string)
symbols = [_[1:-1] for _ in string]
rows = [self._where_by_index(''.join(_)) for _ in combines]
return where_by_index_combine(rows, symbols)
def _where_by_index_subcombine(self, subcombine, string):
'''process statement like: A > 1 and B < 2'''
symbols = PATTERN_AND_OR.findall(string)
rows = [self._where_by_index(_) for _ in subcombine]
return where_by_index_combine(rows, symbols)
def _where_by_index_simple(self, column, string):
'''process statement like: A > 1'''
index = self._sorted_index[column]
operater = (index.equal, index.lower, index.upper)
def clear_pattern(_):
return _.strip().replace('"', '').replace("'", '')
for i, (pattern, symbol, func) in enumerate(zip(PATTERN_EQUALS,
SIMPLE_EQUAL_PATTERN,
operater)):
pattern = [_ for _ in pattern.split(string) if _]
if len(pattern) == 3:
val = clear_pattern(pattern[2])
val = auto_str2value(val)
if pattern[1] == symbol:
if i == 0:
return set(index.unequal(val))
return set(func(val))
try:
return set(func(val, False))
except TypeError:
pass
try:
return set(func(val))
except TypeError:
return set()
pattern = [_ for _ in PATTERN_BETWEEN1.split(string) if _.strip()]
lvalue = auto_str2value(clear_pattern(pattern[4]))
hvalue = auto_str2value(clear_pattern(pattern[0]))
boundary = True, True
for i, pattern in enumerate([pattern[1], pattern[3]]):
if pattern == '>':
boundary[i] = False
return set(index.between(lvalue, hvalue, boundary))
def _where_by_index(self, string):
'''select records according to the sorted index
Analysis the purposes of statements, then return
the indexes of the records which match statements.
Parameters
----------
substring : pythonic string statement
you can write very complex statement like:
eg.1 : A_col >= 3
eg.2 : (B_col <= 2 and 3 >= D_col >= 1) or (A_col == 2 and B_col == 3)
column_pattern : a compiled regex object
used to match the column name in the value
Returns
-------
final_rows : indexes in the list
'''
combines = PATTERN_COMBINE.findall(string)
if combines:
return self._where_by_index_bigcombine(combines, string)
subcombine = PATTERN_AND_OR.split(string)
if len(subcombine) > 1:
return self._where_by_index_subcombine(subcombine, string)
column = self._match_column_from_str(string)
assert len(column) <= 1, 'indexes are only used in processing single column'
assert len(column) == 1, "can't match any column from `%s`" % string
column = column[0]
assert column in self._sorted_index, "`%s` isn't in statement `%s`" % (column, string)
return self._where_by_index_simple(column, string)
def _where_by_rows(self, where, limit):
assert isinstance(limit, int)
assert callable(where), '`where` is not callable, try: Sheet.query(where)'
rows = self.iter_rows
try:
where(tuple())
except AttributeError:
rows = self.__iter__
except TypeError:
rows = self.__iter__
except:
pass
selected = 0
for i, row in enumerate(rows()):
if where(row):
selected += 1
yield i
if selected == limit:
break
def todict(self):
return dict(self.data)
def tolist(self):
'''return the data as lists in list'''
return list(map(list, self.iter_rows()))
def toarray(self):
'''return the data as a numpy.array object'''
try:
from numpy import array
except ImportError:
raise ImportError("can't find numpy library")
return array(tuple(self.iter_rows()))
================================================
FILE: DaPy/core/base/DapyObject.py
================================================
from threading import Lock
from functools import wraps
class Object(object):
'''The base object for DaPy to gurantee threading safety'''
def __init__(self):
self._thread_lock = None
@property
def thread_safety(self):
if self._thread_lock is None:
return False
return True
@thread_safety.setter
def thread_safety(self, mode):
assert mode in (True, False), 'setting `thread_safety` with True or False'
if mode is True:
if self._thread_lock is None:
self._thread_lock = Lock()
else:
self._thread_lock = None
@property
def THREAD_LOCK(self):
return self._thread_lock
def check_thread_locked(func):
def locked_func(self, *args, **kwrds):
lock = self.THREAD_LOCK
if not lock:
return func(self, *args, **kwrds)
with lock:
return func(self, *args, **kwrds)
return locked_func
================================================
FILE: DaPy/core/base/IndexArray.py
================================================
from collections import Sequence
from itertools import chain
from bisect import bisect_left, bisect_right
from operator import itemgetter
from .utils import is_iter, is_value, argsort
class SortedIndex(Sequence):
def __init__(self, array=(), index=()):
assert is_iter(array), '`array` in the index must be iterable'
assert is_iter(index), '`index` in the index must be iterable'
if not index:
self._val = sorted(array)
self._ind = list(argsort(array))
else:
val_ind = sorted(zip(array, index), key=itemgetter(0))
self._val, self._ind = tuple(zip(*val_ind))
self._val, self._ind = list(self._val), list(self._ind)
def __getitem__(self, indices):
if isinstance(indices, (slice, int)):
return self._ind[indices], self._val[indices]
assert IndexError('can not operate like SortedIndex[%s]' % indices)
def __len__(self):
return len(self._val)
def __repr__(self):
if len(self) > 10:
front = ', '.join(map(str, chain(self._val[:5])))
tail = ', '.join(map(str, chain(self._val[-5:])))
values = '[%s, ..., %s]' % (front, tail)
else:
values = str(self._val)
return 'SortedIndex(%s)' % values
def append(self, value):
'''insert a single value to the exists list
This function uses binary select to locate the position,
than insert it into the series.
'''
self.insert(value, len(self._ind))
def between(self, low, high, boundary=(True, True), return_value=False):
'''select values which are between [low, high] and return their index
This function uses binary select to find the values which are between
[low, high], then it will return the index of these values for you.
Parameters
----------
low : value
the lower boundary
high : value
the upper boundary
boundary : bool or bools in tuple (default=(True, True))
(True, True) -> values belong to [low, high]
(True, False) -> values belong to [low, high)
(False, True) -> values belong to (low, high]
(False, False) -> values belong to (low, high)
Returns
-------
index_list : the values index of original data
Examples
--------
>>> original = [4, 23, 31, 33, 34, 34, 21, 23, 33]
>>> index = SortedIndex(original)
>>> index.between(23, 33, (True, True), True)
[23, 23, 31, 33, 33]
>>> index.between(23, 33, (False, True), True)
[31, 33, 33]
>>> index.between(23, 33, (True, False), True)
[23, 23, 31]
>>> index.between(23, 33, (False, False), True)
[31]
'''
if boundary[0] is False:
low_ind = bisect_right(self._val, low)
else:
low_ind = bisect_left(self._val, low)
if boundary[1] is False:
hih_ind = bisect_left(self._val, high)
else:
hih_ind = bisect_right(self._val, high)
if return_value is True:
return self._val[low_ind:hih_ind]
return self._ind[low_ind:hih_ind]
def count(self, value):
'''count how many items euqal to `value`'''
return len(self.equal(value))
def equal(self, value):
'''select the value which is best match given value and return the index'''
try:
return self._ind[self._get_item_index(value)]
except ValueError:
return []
def insert(self, value, index):
'''the index of new value in original sequence is `index`'''
item_index = bisect_left(self._val, value)
self._val.insert(item_index, value)
self._ind.insert(item_index, index)
def _get_item_index(self, value):
'''find the index of the item of the current series'''
item_index_l = bisect_left(self._val, value)
item_index_r = bisect_right(self._val, value)
if item_index_l == item_index_r:
raise ValueError('`%s` is not in this SortedIndex' % value)
if item_index_l != item_index_r - 1:
return slice(item_index_l, item_index_r)
return item_index_l
def index(self, value):
'''find the index of an exacte matched value
This function uses binary select to locate the position
of the matched value in the source index.
Parameters
----------
value : anything
something you want to match with
original_index : bool (default=False)
True: return the index of the value in this row
False: return the index of the value in the source sequence
Returns
-------
int : the index you want to find
Examples
--------
>>> original = [1, 1, 2, 2, 2, 3, 3]
>>> si = SortedIndex(original)
>>> si.index(1) # index of sorted object
[0, 1]
>>> si.index(2)
[2, 3, 4]
>>> si.index(3)
[5, 6]
>>> si.index(5)
ValueError(`5` is not in the current container)
'''
index = self._get_item_index(value)
if isinstance(index, slice):
return [ind for ind in self._ind[index]]
return [self._ind[index]]
def lower(self, value, include_equal=True):
'''find `x` which is lower than `value`, x <= value
This function uses binary select to locate the positions of values which
are less than `value`, and return their indexes of source sequence
Parameters
----------
value : any
the cut point you want to match
include_equal : bool (default=True)
True -> return x <= value
False -> return x < value
Returns
-------
list : index in list
'''
if include_equal is True:
return self._ind[:bisect_right(self._val, value)]
return self._ind[:bisect_left(self._val, value)]
def remove(self, value):
'''remove the value from the Index
It will remove all items which match the value from the Index,
then it will change all indexes which have impacts.
Parameters
----------
value : any
the value you want to remove
Returns
-------
None
Example
-------
>>> source = [3, 4, 2, 4, 5]
>>> index = SortedIndex(source)
>>> index.equal(5)
4
>>> index.remove(4)
>>> index
SortedIndex([2, 3, 5])
>>> index.equal(5)
2
'''
remove_index = self._get_item_index(value)
value_index = sorted(self._ind[remove_index])
del self._ind[remove_index], self._val[remove_index]
self._ind = [ind - bisect_left(value_index, ind) for ind in self._ind]
def upper(self, value, include_equal=True):
'''find `x` which is greater than `value`, x >= value
This function uses binary select to locate the positions of values which
are less than `value`, and return their indexes of source sequence
Parameters
----------
value : any
the cut point you want to match
include_equal : bool (default=True)
True -> return x >= value
False -> return x > value
Returns
-------
list : index in list
'''
if include_equal is True:
return self._ind[bisect_left(self._val, value):]
return self._ind[bisect_right(self._val, value):]
def unequal(self, value):
'''select the items which are not equal to `value`'''
equal_index = set(self.equal(value))
return list(set(self._ind) - equal_index)
if __name__ == '__main__':
original = [4, 23, 31, 33, 34, 34, 21, 23, 33]
index = SortedIndex(original)
assert index.between(23, 33, (True, True), True) == [23, 23, 31, 33, 33]
assert index.between(23, 33, (False, True), True) == [31, 33, 33]
assert index.between(23, 33, (True, False), True) == [23, 23, 31]
assert index.between(23, 33, (False, False), True) == [31]
assert index.index(23) == [1, 7]
index.append(9)
index.append(9)
original.extend([9, 9])
assert str(index), 'SortedIndex([4, 9, 9, 21, 23, ..., 31, 33, 33, 34, 34])'
assert itemgetter(*index.lower(9, True))(original) == (4, 9, 9)
assert itemgetter(*index.lower(9, False))(original) == 4
assert index.equal(23) == [1, 7]
index = SortedIndex(['Jackson', 'Martin', 'John', 'Alice', 'Bob', 'Baker'])
assert index.equal('Bob') == 4
================================================
FILE: DaPy/core/base/LinkedArray.py
================================================
from ctypes import Structure, POINTER, pointer, c_int as C_INT, byref
from collections import Sequence, namedtuple
class intLinkedNode(Structure):
pass
intLinkedNode._fields_ = [
('next_', POINTER(intLinkedNode)),
('val', C_INT),
]
##class LinkedArray(Structure):
## pass
##
##LinkedArray._fields_ = [
## ('root', POINTER(intLinkedNode)),
## ('tail', POINTER(intLinkedNode)),
## ('node', C_INT)
## ]
class intLinkedNode(object):
def __init__(self, next=None, val=None):
self.next = next
self.val = val
def _append_left(link, new_val):
return intLinkedNode(val=new_val, next_=pointer(link))
def _show_values(link):
current_node = link
while bool(current_node):
yield current_node.val
try:
current-node = current_node.next.contents
except ValueError:
break
else:
yield current_node.val
# CFUNCTYPE(restype, *argtypes, **kwrds)
##class LinkedArray(Sequence):
## def __init__(self, iterable=None):
## self.root = intLinkedNode(val=0)
## self.tail = self.root
## self.node = 0
##
## if iterable is not None:
## for value in iterable:
## self.append(value)
##
## def append(self, data):
## self.tail.next = intLinkedNode(val=data) # pointer(next_node)
## self.tail = self.tail.next
## self.node += 1
##
## def __len__(self):
## return self.node
##
## def __getitem__(self, index):
## assert isinstance(index, int)
## for i, node in enumerate(self):
## if i == index:
## return node.val
##
## def __iter__(self):
## current_node = self.root.next# .contents
## while bool(current_node):
## yield current_node.val
## try:
## current_node = current_node.next# .contents
## except ValueError:
## break
## else:
## yield current_node.val
if __name__ == '__main__':
from random import randint
linked = LinkedArray()
for i in range(10):
linked.append(randint(10, 20))
print 'Iter:', [val for val in linked]
print 'Length:', len(linked)
================================================
FILE: DaPy/core/base/Matrix.py
================================================
from array import array
from collections import deque, namedtuple
from copy import copy, deepcopy
from csv import reader
from itertools import chain
from operator import itemgetter
from random import random
from .constant import SEQ_TYPE
from .utils import is_iter, is_math, is_seq
from .utils import filter, map, range, str2float, xrange, zip
__all__ = ['Matrix']
class Matrix(object):
dims = namedtuple('Matrix', ['Ln', 'Col'])
def __init__(self, table=None):
if is_iter(table) and not isinstance(table, str):
self._init_unknow_type(table=table)
elif isinstance(table, Matrix):
self._matrix = copy(table)
self._dim = copy(table._dim)
elif table is None:
self._matrix = list()
self._dim = Matrix.dims(0, 0)
else:
raise TypeError('can not transform %s to DaPy.Matrix' % type(table))
@property
def src(self):
return self._matrix
@property
def shape(self):
return self._dim
@property
def T(self):
new_mat = Matrix()
new_mat._matrix = [list(line) for line in zip(*self._matrix)]
new_mat._dim = Matrix.dims(self.shape.Col, self.shape.Ln)
return new_mat
@property
def I(self):
'''calculating the invert matrix
Reference
---------
1. Bin Luo. (2015). The Implement of Matrix with Python.
from http://www.cnblogs.com/hhh5460/p/4314231.html
'''
assert self._dim.Ln == self._dim.Col, 'can not invert a non-sqrt matrix.'
if self._dim.Ln == 1:
return Matrix(self)
D = self.D
assert D != 0, 'Singular matrix can not calculating the invert matrix.'
if self._dim.Ln == 2:
a, b = self[0]
c, d = self[1]
v = float(a * d - b * c)
return Matrix([[d / v, -b / v], [-c / v, a / v]])
new_mat = Matrix()
new_mat._dim = self._dim
new_mat._matrix = [[(-1) ** (i+j+1) * self._get_cofactor(j, i).D / D for j in xrange(self._dim.Col)] for i in xrange(self._dim.Ln)]
return new_mat
@property
def D(self):
assert self._dim.Ln == self._dim.Col, 'can not determinant a non-sqrt matrix.'
if self._dim.Ln == 2:
return self._matrix[0][0] * self._matrix[1][1] - \
self._matrix[0][1] * self._matrix[1][0]
return float(sum([(-1)**(1+j) * self[0][j] * self._get_cofactor(0, j).D for j in xrange(self._dim.Ln)]))
def __repr__(self):
temporary_series = [list()] * self._dim.Col
if self._dim.Ln > 20:
temporary_Frame = self._matrix[:10]
temporary_Frame.extend(self._matrix[-10:])
else:
temporary_Frame = self._matrix
for line in temporary_Frame:
for i, value in enumerate(line):
temporary_series[i].append(str(value))
column_size = [len(max(col, key=len)) for col in temporary_series]
frame = u'\u250F' + u' ' * (sum(column_size) + len(column_size) - 1) +\
u'\u2513' + u'\n'
if self._dim.Ln > 20:
for i, item in enumerate(temporary_Frame[1:10]):
line = u'\u2503'
for i, value in enumerate(item):
line += str(value).center(column_size[i]) + u' '
frame += line[:-1] + u'\u2503' + u'\n'
frame += u'\u2503'
frame += (u'Omit %d Ln' % (self._dim.Ln - 20)).center(sum(column_size) + len(column_size) - 1)
frame += u'\u2503' + u'\n'
for item in temporary_Frame[-10:]:
line = u'\u2503'
for i, value in enumerate(item):
line += str(value).center(column_size[i]) + u' '
frame += line[:-1] + u'\u2503' + u'\n'
else:
for i, item in enumerate(temporary_Frame):
line = u'\u2503'
for i, value in enumerate(item):
line += str(value).center(column_size[i]) + u' '
frame += line[:-1] + u'\u2503' + u'\n'
frame += u'\u2517' + u' ' * (sum(column_size) + len(column_size) - 1) +\
u'\u251B'
return frame
def __getstate__(self):
instance = self.__dict__.copy()
instance['_dim'] = tuple(self._dim)
return instance
def __setstate__(self, dict):
self._matrix = dict['_matrix']
self._dim = Matrix.dims(*dict['_dim'])
def __contains__(self, e):
if isinstance(e, list):
for record in self._matrix:
if record == e:
return True
return False
def __len__(self):
return self._dim.Ln
def __eq__(self, other):
if hasattr(other, 'shape') and other.shape != self._dim:
return False
elif len(other) != self._dim.Ln or len(other[0]) != self._dim.Col:
return False
try:
size_col = range(self._dim.Col)
for i in range(self._dim.Ln):
for j in size_col:
if self._matrix[i][j] != other[i][j]:
return False
except:
return False
else:
return True
def __getitem__(self, pos):
if isinstance(pos, (slice, int)):
return copy(self._matrix[pos])
if isinstance(pos, tuple):
assert len(pos) == 2, 'too many indices for array.'
return Matrix([record[pos[1]] for record in self._matrix[pos[0]]])
def __setitem__(self, pos, value):
if isinstance(pos, tuple):
warn = 'position must be like mat[i, j], not mat[%s]' % (pos,)
assert isinstance(pos[0], (type(None), int, slice)), warn
assert isinstance(pos[1], (type(None), int, slice)), warn
assert is_math(value), 'the value in the matrix must be a number.'
self._matrix[pos[0]][pos[1]] = value
elif isinstance(pos, int):
assert abs(pos) <= self.shape.Ln, 'position of %d is out of range' % pos
if is_math(value):
self._matrix[pos] = [value] * self.shape.Col
if is_seq(value):
assert len(value) == self._dim.Col, 'cannot copy sequence with size %d to array axis with dimension %d' % (len(value), self.shape.Col)
self._matrix[pos] = list(value)
else:
raise TypeError('only supports to set a record as line or a single value.')
def __iter__(self):
for line in self._matrix:
yield list(line)
def __int__(self):
mat = Matrix()
mat._matrix = [list(map(int, row)) for row in self._matrix]
mat._dim = self.shape
return mat
def __ne__(self, other):
if self.__eq__(other):
return False
return True
def __neg__(self):
neg = Matrix()
neg._dim = Matrix.dims(self._dim.Ln, self._dim.Col)
neg._matrix = [0] * self._dim.Ln
for i, line in enumerate(self._matrix):
neg._matrix[i] = array('f', (value.__neg__() for value in line))
return neg
def __pos__(self):
neg = Matrix()
neg._dim = Matrix.dims(self._dim.Ln, self._dim.Col)
neg._matrix = [0] * self._dim.Ln
for i, line in enumerate(self._matrix):
neg._matrix[i] = array('f', (value.__pos__() for value in line))
return new
def __sum__(self, other):
return sum(sum(record) for record in self._matrix)
def __abs__(self):
neg = Matrix()
neg._dim = Matrix.dims(self._dim.Ln, self._dim.Col)
neg._matrix = [0] * self._dim.Ln
for i, line in enumerate(self._matrix):
neg._matrix[i] = tuple(value.__abs__() for value in line)
return new
def __add__(self, other):
new_ = [0] * self._dim.Ln
if is_math(other):
for i in range(self._dim.Ln):
new_[i] = array('f', (self._matrix[i][j] + other\
for j in xrange(self._dim.Col)))
elif hasattr(other, 'shape'):
x1, y1 = self.shape
x2, y2 = other.shape
if x1 == x2 and y1 == y2:
for i in range(self._dim.Ln):
new_[i] = array('f', (self._matrix[i][j] + other[i][j]\
for j in xrange(self._dim.Col)))
elif x1 == x2 and y1 == 1 or y2 == 1:
for i in range(self._dim.Ln):
new_[i] = array('f', (self._matrix[i][j] + other[i][0]\
for j in xrange(self._dim.Col)))
elif y1 == y2 and x1 == 1 or x2 == 1:
for i in range(self._dim.Ln):
new_[i] = array('f', (self._matrix[i][j] + other[0][j]\
for j in xrange(self._dim.Col)))
else:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d, %d) and '%self._dim+\
'(%d, %d)'%other.shape)
else:
raise TypeError("'+' operation expects the type of"+\
"number or an array-like object which has "+\
"attribute `shape`")
return Matrix(new_)
def __radd__(self, other):
return self.__add__(other)
def __sub__(self, other):
new_ = Matrix()
mat = new_._matrix
if is_math(other):
new_._dim = self.shape
for row in self._matrix:
mat.append([x - other for x in row])
elif hasattr(other, 'shape'):
x1, y1 = self.shape
x2, y2 = other.shape
new_._dim = Matrix.dims(max(x1, x2), max(y1, y2))
if x1 == x2:
if y1 == y2:
for lrow, rrow in zip(self._matrix, other):
mat.append([l - r for l,r in zip(lrow, rrow)])
if y2 == 1:
for lrow, rrow in zip(self._matrix, other):
mat.append([l - rrow[0] for l in lrow])
if y1 == 1:
for lrow, rrow in zip(self._matrix, other):
mat.append([lrow[0] - r for r in rrow])
elif y1 == y2:
if x1 == 1:
sub_line = self._matrix[0]
for rrow in other:
mat.append([l - r for l,r in zip(sub_line, rrow)])
if x2 == 1:
sub_line = other[0]
for lrow in self:
mat.append([l - r for l,r in zip(lrow, sub_line)])
else:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d, %d) and '%self._dim+\
'(%d, %d)'%other.shape)
else:
try:
return self.__sub__(Matrix(other))
except:
raise TypeError("'-' operation expects the type of"+\
"number or an array-like object which has "+\
"attribute `shape`")
return new_
def __rsub__(self, other):
new_ = Matrix()
mat = new_._matrix
if is_math(other):
new_._dim = self.shape
for row in self._matrix:
mat.append([other - x for x in row])
elif hasattr(other, 'shape'):
x1, y1 = self.shape
x2, y2 = other.shape
new_._dim = Matrix.dims(max(x1, x2), max(y1, y2))
if x1 == x2:
if y1 == y2:
for lrow, rrow in zip(other, self._matrix):
mat.append([l - r for l,r in zip(lrow, rrow)])
if y2 == 1:
for lrow, rrow in zip(other, self._matrix):
mat.append([l - rrow[0] for l in lrow])
if y1 == 1:
for lrow, rrow in zip(other, self._matrix):
mat.append([lrow[0] - r for r in rrow])
elif y1 == y2:
if x1 == 1:
sub_line = self._matrix[0]
for rrow in other:
mat.append([l - r for l,r in zip(sub_line, rrow)])
if x2 == 1:
sub_line = other[0]
for lrow in self:
mat.append([l - r for l,r in zip(lrow, sub_line)])
else:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d, %d) and '%self._dim+\
'(%d, %d)'%other.shape)
else:
try:
return self.__sub__(Matrix(other))
except:
raise TypeError("'-' operation expects the type of"+\
"number or an array-like object which has "+\
"attribute `shape`")
return new_
def __mul__(self, other):
new_ = Matrix()
mat = new_._matrix
if is_math(other):
new_._dim = self.shape
for row in self._matrix:
mat.append([x * other for x in row])
elif hasattr(other, 'shape'):
x1, y1 = self.shape
x2, y2 = other.shape
new_._dim = Matrix.dims(max(x1, x2), max(y1, y2))
if x1 == x2:
if y1 == y2:
for lrow, rrow in zip(self._matrix, other):
mat.append([l * r for l,r in zip(lrow, rrow)])
if y2 == 1:
for lrow, rrow in zip(self._matrix, other):
mat.append([l * rrow[0] for l in lrow])
if y1 == 1:
for lrow, rrow in zip(self._matrix, other):
mat.append([lrow[0] * r for r in rrow])
elif y1 == y2:
if x1 == 1:
sub_line = self._matrix[0]
for rrow in other:
mat.append([l * r for l,r in zip(sub_line, rrow)])
if x2 == 1:
sub_line = other[0]
for lrow in self:
mat.append([l * r for l,r in zip(lrow, sub_line)])
else:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d, %d) and '%self._dim+\
'(%d, %d)'%other.shape)
else:
try:
return self.__mul__(Matrix(other))
except:
raise TypeError("'*' operation expects the type of"+\
"number or an array-like object which has "+\
"attribute `shape`")
return new_
def __rmul__(self, other):
return self.__mul__(other)
def __div__(self, other):
new_ = Matrix()
mat = new_._matrix
if is_math(other):
new_._dim = self.shape
for row in self._matrix:
mat.append([x / other for x in row])
elif hasattr(other, 'shape'):
x1, y1 = self.shape
x2, y2 = other.shape
if x2 == y2 == 1 and hasattr(other, 'tolist'):
return self.__div__(other.tolist()[0][0])
new_._dim = Matrix.dims(max(x1, x2), max(y1, y2))
if x1 == x2:
if y1 == y2:
for lrow, rrow in zip(self._matrix, other):
mat.append([l / r for l,r in zip(lrow, rrow)])
if y2 == 1:
for lrow, rrow in zip(self._matrix, other):
mat.append([l / rrow[0] for l in lrow])
if y1 == 1:
for lrow, rrow in zip(self._matrix, other):
mat.append([lrow[0] / r for r in rrow])
elif y1 == y2:
if x1 == 1:
sub_line = self._matrix[0]
for rrow in other:
mat.append([l / r for l,r in zip(sub_line, rrow)])
if x2 == 1:
sub_line = other[0]
for lrow in self:
mat.append([l / r for l,r in zip(lrow, sub_line)])
else:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d, %d) and '%self._dim+\
'(%d, %d)'%other.shape)
else:
try:
return self.__div__(Matrix(other))
except:
raise TypeError("'/' operation expects the type of"+\
"number or an array-like object which has "+\
"attribute `shape`")
return new_
def __truediv__(self, other):
return self.__div__(other)
def __rdiv__(self, other):
new_ = Matrix()
mat = new_._matrix
if is_math(other):
new_._dim = self.shape
for row in self._matrix:
mat.append([other / x for x in row])
elif hasattr(other, 'shape'):
x1, y1 = self.shape
x2, y2 = other.shape
if x2 == y2 == 1 and hasattr(other, 'tolist'):
return self.__rdiv__(other.tolist()[0][0])
new_._dim = Matrix.dims(max(x1, x2), max(y1, y2))
if x1 == x2:
if y1 == y2:
for lrow, rrow in zip(other, self._matrix):
mat.append([l / r for l,r in zip(lrow, rrow)])
if y2 == 1:
for lrow, rrow in zip(other, self._matrix):
mat.append([l / rrow[0] for l in lrow])
if y1 == 1:
for lrow, rrow in zip(other, self._matrix):
mat.append([lrow[0] / r for r in rrow])
elif y1 == y2:
if x1 == 1:
sub_line = self._matrix[0]
for rrow in other:
mat.append([l / r for l,r in zip(sub_line, rrow)])
if x2 == 1:
sub_line = other[0]
for lrow in self:
mat.append([l / r for l,r in zip(lrow, sub_line)])
else:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d, %d) and '%self._dim+\
'(%d, %d)'%other.shape)
else:
try:
return self.__rdiv__(Matrix(other))
except:
raise TypeError("'/' operation expects the type of"+\
"number or an array-like object which has "+\
"attribute `shape`")
return new_
def __rtruediv__(self, other):
return self.__rdiv__(other)
def __pow__(self, other):
new_ = [0] * self._dim.Ln
if is_math(other):
for i in range(self._dim.Ln):
new_[i] = [self._matrix[i][j] ** other\
for j in range(self._dim.Col)]
elif hasattr(other, 'shape'):
if self.shape != other.shape:
raise ValueError('operands could not be broadcast '+\
'together with shapes '+\
'(%d,%d) '%self._dim+\
'(%d,%d)'%other._dim)
for i in range(self._dim.Ln):
new_[i] = [self._matrix[i][j] ** other[i][j]\
for j in range(self._dim.Col)]
else:
raise TypeError("'**' operation expects the type of "+\
"number or an array-like object which has "+\
"attribute `shape`")
return Matrix(new_)
def _get_cofactor(self, i, j):
mat = self._matrix
return Matrix([r[:j] + r[j+1:] for r in (mat[:i]+mat[i+1:])])
def _init_unknow_type(self, table):
if hasattr(table, 'tolist'):
table = table.tolist()
try:
self._matrix = [array('f', row).tolist() for row in table]
except TypeError:
self._matrix = [array('f', table).tolist(),]
self._dim = self._init_src_shape(self._matrix)
@classmethod
def _init_src_shape(cls, src, judge_shape=True):
lenth = tuple(map(len, src))
max_lenth = max(lenth)
assert lenth.count(max_lenth) == len(lenth), 'not uniqual dimension of rows'
return cls.dims(len(lenth), max_lenth)
def argmax(self, axis=None):
'''Indexes of the maxium values along an axis.
Example
-------
>>> x = dp.mat(range(10)).reshape((3, 4))
>>> x.argmax()
>>> x.argmax(0)
>>> x.argmax(1)
'''
if axis is None:
iter_each_values = (value for row in self._matrix for value in row)
return max(enumerate(iter_each_values), key=itemgetter(1))[0]
if axis == 0:
return Matrix(max(enumerate(col), key=itemgetter(1)) for col in zip(*self._matrix))[:, 0].T
return Matrix(max(enumerate(row), key=itemgetter(1)) for row in self._matrix)[:, 0].T
def diagonal(self):
return [self._matrix[i][i] for i in xrange(min(self.shape))]
def dot(self, other):
if hasattr(other, 'shape') is False:
return self.dot(Matrix(other))
assert len(other.shape) == 2, 'unexpect data shape of %s' % other.shape
assert self.shape[1] == other.shape[0], 'shapes (%d, %d)' % self._dim +\
' and (%d, %d) not aligned.'%other._dim
col_size = other.shape[1]
new = Matrix()
new._dim = Matrix.dims(self.shape.Ln, other.shape[1])
now = new._matrix
for lineI in self._matrix:
now.append([sum(left * right[pos] for left, right in zip(lineI, other)) for pos in xrange(col_size)])
return new
@classmethod
def make(cls, Ln, Col, element=0):
if not (isinstance(Ln, int) and isinstance(Col, int)):
raise TypeError("arguments 'Ln' and 'Col' expect <int> type")
cls = cls()
cls._matrix = [[element] * Col for j in xrange(Ln)]
cls._dim = Matrix.dims(Ln, Col)
return cls
@classmethod
def make_random(cls, Ln, Col, type_int=False):
if not (isinstance(Ln, int) and isinstance(Col, int)):
raise TypeError("arguments `Ln` and `Col` expect <int> type,")
if not isinstance(type_int, (bool, tuple)):
raise TypeError("argutments `type_int` expects `False` symbol"+\
" or a tuple-like.")
cls = cls()
cls._matrix = [0] * Ln
if type_int:
for i in range(Ln):
self._matrix[i] = array('f', [randint(*type_int)] * Col)
else:
for i in range(Ln):
self._matrix[i] = array('f', [random()] * Col)
cls._dim = Matrix.dims(Ln, Col)
return cls
@classmethod
def make_eye(cls, size, value=None):
assert is_math(value) or value is None or hasattr(value, '__iter__'), 'value should be a list of number, number or None.'
if value is None:
value == [1.0] * size
elif is_math(value):
value = [value] * size
cls = cls()
cls._matrix = [array('f', [0.0] * size) for j in range(size)]
cls._dim = Matrix.dims(size, size)
for i in xrange(size):
cls._matrix[i][i] = value[i]
return cls
@classmethod
def from_text(cls, addr, **kward):
first_line = kward.get('first_line', 1)
sep = kward.get('sep', ',')
cls = cls()
with open(addr, 'r') as f:
_reader = reader(f, delimiter=sep)
for m, record in enumerate(_reader):
if m >= first_line - 1:
break
for record in _reader:
cls._matrix.append(array('f', map(str2float, record)))
col = len(max(cls._matrix, key=len))
for record in cls._matrix:
if len(record) != col:
record.extend([0.0] * (col - len(record)))
cls._dim = Matrix.dims(len(cls._matrix), col)
return cls
def reshape(self, new_shape):
x, y = new_shape
size = self.shape.Ln * self.shape.Col
assert x * y == size, "can't reshape matrix of size %d into shape %s" % (size, new_shape)
new = Matrix()
new._dim = Matrix.dims(new_shape[0], new_shape[1])
row = []
for i, value in enumerate(chain(*self._matrix), 1):
row.append(value)
if i % y == 0:
new._matrix.append(row)
row = []
return new
def tolist(self):
if self._dim.Col == 1:
return [record[0] for record in self._matrix]
return copy(self._matrix)
================================================
FILE: DaPy/core/base/Series.py
================================================
from copy import copy
from collections import Counter
from itertools import repeat, compress, accumulate
from datetime import datetime, timedelta
from operator import add, sub, mul, mod, pow
from operator import eq, gt, ge, lt, le
from operator import itemgetter
from math import sqrt
from heapq import nlargest, nsmallest
from time import clock
try:
from numpy import darray
except ImportError:
darray = list
from .constant import STR_TYPE, VALUE_TYPE, SEQ_TYPE, DUPLICATE_KEEP, PYTHON3, nan
from .utils import filter, map, range, xrange, zip, zip_longest
from .utils import is_iter, is_math, is_seq, is_value, isnan, auto_plus_one
from .utils.utils_isfunc import SET_SEQ_TYPE
if PYTHON3:
from operator import truediv as div, itemgetter
else:
from operator import div, itemgetter
SHAPE_UNEQUAL_WARNING = "can't broadcast together with lenth %d and %d"
def quickly_apply(operation, left, right):
assert callable(operation) is True
return Series(map(operation, left, right))
getter1, getter0 = itemgetter(1), itemgetter(0)
class Series(list):
def __init__(self, array=[]):
if is_iter(array) is False:
array = (array,)
list.__init__(self, array)
@property
def data(self):
return self
@property
def shape(self):
return (len(self), 1)
def __repr__(self):
if len(self) > 10:
head = ','.join(map(str, self[:5]))
tail = ','.join(map(str, self[-5:]))
return 'Sereis([%s, ..., %s])' % (head, tail)
return 'Series(%s)' % list.__repr__(self)
def __eq__(self, other):
other = self._check_operate_value(other)
return quickly_apply(eq, self, other)
def __gt__(self, other):
other = self._check_operate_value(other)
return quickly_apply(gt, self, other)
def __ge__(self, other):
other = self._check_operate_value(other)
return quickly_apply(ge, self, other)
def __lt__(self, other):
other = self._check_operate_value(other)
return quickly_apply(lt, self, other)
def __le__(self, other):
other = self._check_operate_value(other)
return quickly_apply(le, self, other)
def __setitem__(self, key, val):
'''refresh data from current series
Parameters
----------
key : slice, int, same-size series and tuple
val : single value or iterable container
Return
------
None
'''
setitem = list.__setitem__
if isinstance(key, int):
setitem(self, key, val)
if isinstance(key, Series):
err = 'Index should be same size with current series'
assert len(key) == len(self), err
for i, key in enumerate(key):
if key is True:
setitem(self, key, val)
if is_seq(key):
for key in key:
setitem(self, key, val)
if isinstance(key, slice):
start = 0 if key.start is None else key.start
stop = len(self) if key.stop is None else key.stop
step = 1 if key.step is None else key.step
start = start if start > 0 else start + len(self)
stop = start if stop > 0 else stop + len(self)
val = repeat(val, int((stop - start) / 2)) if is_value(val) else val
setitem(self, key, val)
def __getitem__(self, key):
'''get data from current series
Parameters
----------
key : slice, int, same-size series and tuple
Return
------
number or numbers in Series
Example
-------
>>> ser = Series(range(2, 10))
>>> ser[2:5] # get elements by slice
[4, 5, 6]
>>> ser[-1] # get element by index
9
>>> ser[ser > 4] # get elements by sequence of bool
[5, 6, 7, 8, 9]
>>> ser[2, 4, 2, 3] # get elements by multiple index
[4, 6, 4, 5]
'''
if isinstance(key, int):
return list.__getitem__(self, key)
if isinstance(key, Series):
assert len(key) == len(self)
return Series(compress(self, key))
if is_seq(key):
if len(key) == 1:
return Series([list.__getitem__(self, key[0])])
if len(key) < len(self) * 0.1:
return Series(map(list.__getitem__, repeat(self, len(key)), key))
if is_iter(key):
try:
key = itemgetter(*key)
except TypeError:
return Series()
if isinstance(key, itemgetter):
list_self = list(self)
return Series(key(list_self))
if isinstance(key, slice):
return Series(list.__getitem__(self, key))
def __delitem__(self, key):
'''delete data from current series
Parameters
----------
key : slice, int, same-size series and tuple
Return
------
number or numbers in Series
Example
-------
>>> ser = Series(range(2, 10))
>>> ser[2:5] # get elements by slice
[4, 5, 6]
>>> ser[-1] # get element by index
9
>>> ser[ser > 4] # get elements by sequence of bool
[5, 6, 7, 8, 9]
>>> ser[2, 4, 2, 3] # get elements by multiple index
[4, 6, 4, 5]
'''
func = list.__delitem__
if isinstance(key, int):
return func(self, key)
if isinstance(key, Series):
assert len(key) == len(self)
for ind, val in enumerate(key):
if val:
func(self, ind)
if isinstance(key, (tuple, list)):
key = sorted(set(key), reverse=True)
for ind in key:
func(self, ind)
if isinstance(key, slice):
func(self, key)
def __getslice__(self, start, stop):
return Series(list.__getslice__(self, start, stop))
def _check_operate_value(self, value):
lself = len(self)
if is_value(value):
return repeat(value, lself)
if hasattr(value, 'len') is False:
value = list(value)
rl = len(value)
assert lself == rl, SHAPE_UNEQUAL_WARNING % (lself, rl)
return value
def __add__(self, right):
'''[1, 2, 3] + 3 -> [4, 5, 6]
[1, 2, 3] + [4, 5, 6] -> [5, 7, 9]
'''
right = self._check_operate_value(right)
return quickly_apply(add, self, right)
def __radd__(self, left):
'''3 + [1, 2, 3] -> [4, 5, 6]
'''
left = self._check_operate_value(left)
return quickly_apply(add, left, self)
def __sub__(self, right):
'''[1, 2, 3] - 3 -> [-2, -1 ,0]
'''
value = self._check_operate_value(right)
return quickly_apply(sub, self, value)
def __rsub__(self, left):
'''3 - [1, 2, 3] -> [2, 1, 0]
'''
value = self._check_operate_value(left)
return quickly_apply(sub, value, self)
def __mul__(self, right):
'''[1, 2, 3] * 3 -> [3, 6, 9]
'''
value = self._check_operate_value(right)
return quickly_apply(mul, self, value)
def __rmul__(self, left):
'''3 * [1, 2, 3] -> [3, 6, 9]
'''
value = self._check_operate_value(left)
return quickly_apply(mul, value, self)
def __div__(self, right):
'''[1, 2, 3] / 2 -> [0.5, 1, 1.5]
'''
value = self._check_operate_value(right)
return quickly_apply(div, self, value)
def __truediv__(self, right):
return self.__div__(right)
def __rdiv__(self, left):
'''3 / [1, 2, 3] -> [3, 1.5, 1]
'''
value = self._check_operate_value(left)
return quickly_apply(div, value, self)
def __mod__(self, right):
'''[1, 2, 3] % 3 -> [0, 0, 1]
'''
value = self._check_operate_value(right)
return quickly_apply(mod, self, value)
def __rmod__(self, left):
'''3 % [1, 2, 3] -> [3, 1, 1]
'''
value = self._check_operate_value(left)
return quickly_apply(mod, value, self)
def __pow__(self, right):
'''[1, 2, 3] ** 2 -> [1, 4, 9]
'''
value = self._check_operate_value(right)
return quickly_apply(pow, self, value)
def __float__(self):
'''float([1, 2, 3]) -> [1.0, 2.0, 3.0]
'''
return Series(map(float, self))
def __abs__(self):
'''abs([-1, 2, -3]) -> [1, 2, 3]
'''
return Series(map(abs, self))
def abs(self):
return self.__abs__()
def accumulate(self, func=None, skipna=True):
'''return accumulate for each item in the series'''
assert skipna in (True, False), '`skipna` must be True or False'
values = Series(self) if skipna else self
if skipna:
index_nan = [i for i, val in enumerate(self) if isnan(val)]
values[index_nan] = 0.0
return Series(accumulate(values, func))
def apply(self, func, *args, **kwrds):
return Series(func(val, *args, **kwrds) for val in self)
def argmax(self):
max_val, max_ind = - float('inf'), None
for ind, val in enumerate(self):
if val > max_val:
max_val, max_ind = val, ind
return max_ind
def argmin(self):
max_val, max_ind = float('inf'), None
for ind, val in enumerate(self):
if val < max_val:
max_val, max_ind = val, ind
return max_ind
def argsort(self, key=None, reverse=False):
'''return the indices that would sort an array
Parameters
----------
key : function or None (default=None)
reverse : True or False (default=False)
Return
------
Series : index of original data
Example
-------
>>> Series([5, 2, 1, 10]).argsort()
Series([2, 1, 0, 3])
'''
return Series(map(getter0, sorted(enumerate(self), key=getter1, reverse=reverse)))
def between(self, left, right, boundary='both'):
'''select the values which fall between `left` and `right`
this function quickly select the values which are larger
than `left` as well as smaller than `right`
Parameters
----------
left : val
to select values which are all larger than `left`
right : val
to select values which are all less than `right`
boundary : 'both', False, 'left', 'right (default='both')
'''
assert boundary in ('both', False, 'left', 'right')
bound_left, bound_right = ge, ge
if boundary in (False, 'right'):
bound_left = gt
if boundary in (False, 'left'):
bound_right = gt
def func(x):
bound_left(left, x) and bound_rgiht(right, x)
return Series(map(func, self))
def cv(self):
Ex, Ex2, length = 0, 0, float(len(self))
if length <= 1:
return 0
for val in self:
Ex += val
Ex2 += pow(val, 2)
if Ex == 0:
return sqrt((Ex2 - Ex ** 2 / length) / (length - 1.0))
return sqrt((Ex2 - Ex ** 2 / length) / (length - 1.0)) / (Ex / length)
def count_values(self):
'''return a counter object that contains frequency of values'''
return Counter(self)
def diff(self, lag):
'''return a differential series that has only len(arr) - lag elements'''
getter = list.__getitem__
return Series(getter(self, i) - getter(self, i - lag) for i in range(lag, len(self)))
def drop(self, todrop):
'''remove values that matches `label` from the series'''
if is_seq(todrop) is False:
todrop = (todrop,)
todrop = set(todrop)
return Series(filter(lambda val: val not in todrop, self))
def drop_duplicates(self, keep=['first', 'last', False]):
assert keep in ('first', 'last', False)
# find the all ununiqual values: O(n)
val_ind = {}
for i, value in enumerate(self):
val_ind.setdefault(value, []).append(i)
# get index from the quickly preview table: O(k)
to_drop_index, keep_arg = set(), DUPLICATE_KEEP[keep]
for value, index in val_ind.items():
if len(index) != 1:
to_drop_index.update(index[keep_arg])
# drop out these index: O(n)
return Series((val for i, val in enumerate(self) if i not in to_drop_index))
def dropna(self):
return Series(filter(lambda val: not isnan(val), self))
def get(self, index, default=None):
try:
return list.__getitem__(self, index)
except Exception:
return default
def has_duplicates(self):
return len(self) != len(set(self))
def normalize(self):
mini, maxm = float(min(self)), max(self)
rang = maxm - mini
return Series(map(lambda x: (x - mini) / rang, self))
def isnan(self):
return Series(map(isnan, self))
def map(self, func):
'''given a map, return values that are tranformed by map
Parameters
----------
func : callable-object or dict
Return
------
Series : mapped values
Examples
--------
>>> arr = dp.Series([3, 5, 7, 1])
>>> arr.map(lambda val: val + 1)
Series([4, 6, 8, 2])
>>> arr.map({3: 'C'})
Series(['C', 5, 7, 1])
'''
if hasattr(func, '__getitem__'):
func = lambda val: obj.__getitem__(val) if val in obj else val
assert callable(func), '`func` expects a callable object or dict-like object'
return Series(map(func, self))
def max(self, axis=0):
return max(self)
def max_n(self, n=1):
return Series(nlargest(n, self))
def min(self, axis=0):
return min(self)
def min_n(self, n=1):
return Series(nsmallest(1, self))
def mean(self, axis=0):
return sum(self, 0.0) / len(self)
def percenttile(self, q):
return sorted(self)[int(q * len(self))]
def pop(self, ind):
if isinstance(ind, int):
return list.pop(self, ind)
if isinstance(ind, slice):
start, stop = ind.start, ind.stop
return Series(list.pop(self, i) for i in xrange(start, stop))
if is_seq(ind):
ind = sorted(set(ind), reverse=True)
to_ret = Series(list.pop(self, i) for i in ind)
to_ret.reverse()
return to_ret
def replace(self, old, new):
return Series(new if _ == old else _ for _ in self)
def sum(self):
return sum(self, 0.0)
def std(self):
Ex, Ex2, length = 0, 0, float(len(self))
if length <= 1:
return 0
for val in self:
Ex += val
Ex2 += pow(val, 2)
return sqrt((Ex2 - Ex ** 2 / length) / (length - 1.0))
def tolist(self):
return list(self)
def toarray(self):
try:
from numpy import array
return array(self)
except ImportError:
raise ImportError("can't find numpy")
def unique(self):
'''return unique items in the series'''
uniq_vals, temp_vals = Series(), set()
additem, appitem = set.add, list.append
for i, val in enumerate(self):
if val not in uniq_vals:
additem(temp_vals, val)
appitem(uniq_vals, val)
return uniq_vals
SET_SEQ_TYPE.add(Series)
if __name__ == '__main__':
init = Series(xrange(2, 8))
assert all(init == [2, 3, 4, 5, 6, 7])
assert len(init) == 6
assert str(init) == 'Series([2, 3, 4, 5, 6, 7])'
assert all(init[2:5] == [4, 5, 6])
assert init[-1] == 7
assert all(init[init >= 4] == [4, 5, 6, 7])
assert all(init + 1 == [3, 4, 5, 6, 7, 8])
assert all(init + init == [4, 6, 8, 10, 12, 14])
assert all(init - 1 == [1, 2, 3, 4, 5, 6])
assert all(init - init == [0, 0, 0, 0, 0, 0])
assert all(init * 1 == [2, 3, 4, 5, 6, 7])
assert all(init * init == [4, 9, 16, 25, 36, 49])
assert all(init / 2.0 == [1, 1.5, 2, 2.5, 3, 3.5])
assert all(init / init == [1, 1, 1, 1, 1, 1])
assert all(1.0 + init == [3, 4, 5, 6, 7, 8])
assert all(1 - init == [-1, -2, -3, -4, -5, -6])
assert all(1 * init == [2, 3, 4, 5, 6, 7])
assert all(10.0 / init == [5.0, 3.3333333333333335, 2.5, 2.0, 1.6666666666666667, 1.4285714285714286])
================================================
FILE: DaPy/core/base/Sheet.py
================================================
'''
This file is a part of DaPy project
We define three base data structures for operating
data like an excel. In contrsat with Pandas, it is more
convinience and more simply to use.
BaseSheet is a rudimentary structure and it provides some
functions which have no different between SeriesSet and
Frame structures.
'''
from collections import Counter
from copy import copy
from datetime import datetime
from itertools import chain, repeat
from operator import eq, ge, gt, le, lt
from re import compile as re_compile
from .BaseSheet import BaseSheet
from .constant import (DUPLICATE_KEEP, PYTHON2, PYTHON3, SHEET_DIM, STR_TYPE,
VALUE_TYPE)
from .constant import nan as NaN
from .DapyObject import check_thread_locked
from .IndexArray import SortedIndex
from .Row import Row
from .Series import Series
from .utils import (argsort, auto_plus_one, auto_str2value, count_nan,
fast_str2value, hash_sort, is_dict, is_empty, is_iter,
is_math, is_seq, is_str, is_value, isnan, range, split,
str2date, strip, xrange, zip_longest, count_str_printed_length)
from .utils.utils_join_table import inner_join, left_join, outer_join
from .utils.utils_regression import simple_linear_reg
__all__ = ['SeriesSet']
class SeriesSet(BaseSheet):
'''Variable stores in sequenes
'''
def __init__(self, series=None, columns=None, nan=float('nan')):
self._data = dict()
BaseSheet.__init__(self, series, columns, nan)
@property
def info(self):
'''summary the information of sheet'''
self.describe(level=0)
@property
def missing(self):
'''self.missing -> number of missing values in each column'''
return SeriesSet([self._missing], self.columns)[0]
@property
def T(self):
'''transpose the current data set -> SeriesSet'''
return SeriesSet(self.iter_values(), None, self.nan)
def __eq__(self, other):
'''Sheet1 == 3 -> Bool in sheet'''
if is_value(other):
return self.__compare_value__(other, SeriesSet(nan=self.nan), eq)
if other.shape.Ln != self.shape.Ln:
return False
if other.shape.Col != self.shape.Col:
return False
if other.columns != self.columns:
return False
for lval, rval in zip(other.iter_values(), self.iter_values()):
if (lval == rval).all() is False:
return False
return True
def __gt__(self, other):
return self.__compare_value__(other, SeriesSet(nan=self.nan), gt)
def __ge__(self, other):
return self.__compare_value__(other, SeriesSet(nan=self.nan), ge)
def __lt__(self, other):
return self.__compare_value__(other, SeriesSet(nan=self.nan), lt)
def __le__(self, other):
return self.__compare_value__(other, SeriesSet(nan=self.nan), le)
@check_thread_locked
def accumulate(self, func=None, cols=None, skipna=True, inplace=False):
'''accumulate(func=None, cols=None, skpna=True, inplace=False) -> SeriesSet
return accumulated values for sequences
Parameters
----------
func : callable-object or None (default=None)
the function used to operate each two values, default is `add`
col : str, str in list (default='all')
the columns that you expect to process
skipna : True / False (default=True)
whether accumulate values without NaN
Attention: in this function, we support float('nan') as NaN only
inplace : True or False (default=0)
update values in current dataset or return new values
Returns
-------
accumulated_data : SeriesSet
'''
assert inplace in (True, False), '`inplace` must be True or False'
if inplace is False:
return SeriesSet(self)._accumulate(func, cols, skipna)
return self._accumulate(func, cols, skipna)
@check_thread_locked
def append_col(self, series, variable_name=None):
'''append_col([1, 2, 3], 'New_column') -> None
Append a new variable named `variable_name` with a list of data
`series` at the tail of sheet.
Setting a series of data as a new variable at the sheet.
Parameters
----------
series : list
variable_name : str or None (default=None)
the new variable name, if it is None, it will
automatically add one.
Returns
-------
None
Examples
--------
>>> import DaPy as dp
>>> sheet = dp.SeriesSet()
>>> sheet.append_col([1, 2, 3], variable_name='A')
>>> sheet
A: <1, 2, 3>
>>> sheet.append_col([1, 2, 3, 4, 5], variable_name='A')
>>> sheet
A: <1, 2, 3, nan, nan>
A_1: <1, 2, 3, 4, 5>
>>> sheet.append_col([0, 0])
>>> sheet
A: <1, 2, 3, nan, nan>
A_1: <1, 2, 3, 4, 5>
C_2: <0, 0, nan, nan, nan>
Notes
-----
1. This function has been added into unit test.
2. Function won't be locked when sheet.locked is False
'''
self._append_col(series, variable_name)
return self
@check_thread_locked
def append_row(self, row):
'''append_row(row=[1, 2, 3]) -> None
Append a new record `row` at the tail of sheet.
Using this to append a set of data as a new row in to
the tail of current sheet. It will automatically add
new columns if the new row is longer than the exist
columns. When the length of the new row is smaller
than the number of columns, the new row will be automatically
addded NaN.
Parameters
----------
row : dict, namedtuple, list, tuple
a new row
Returns
-------
None
Examples
--------
>>> import DaPy as dp
>>> sheet = dp.SeriesSet(columns=['A', 'B', 'C'])
>>> sheet.append_row([3, 4, 5]) # a list of new row
>>> sheet.show()
A | B | C
---+---+---
3 | 4 | 5
>>> # a dict of new row which has much more values
>>> sheet.append_row(dict(A=1, B=2, C=3, D=4))
>>> sheet.show()
A | B | C | D
---+---+---+-----
3 | 4 | 5 | nan
1 | 2 | 3 | 4
>>> # length is less than the number of columns
>>> sheet.append_row([9])
A | B | C | D
---+-----+-----+-----
3 | 4 | 5 | nan
1 | 2 | 3 | 4
9 | nan | nan | nan
Notes
-----
1. This function has been added into unit test.
2. Function won't be locked when sheet.locked is False
'''
self._append_row(row)
return self
def apply(self, func, cols=None, axis=0, *args, **kwrds):
'''apply(func, col=None, *args, **kwrds)
apply a function to columns or rows
Parameters
----------
func : callable
the function that you need to process the data
col : str, str in list (default='all')
the columns that you expect to process
axis : 1 or 0 (default=0)
apply the function along rows(0) or columns(1)
Returns
-------
applied_sheet : SeriesSet
Example
-------
>>> sheet = dp.Table([[1, 2, 3], [4, 5, 6]])
>>> func = lambda arr: arr.sum() / arr.std()
>>> sheet.apply(func, axis=1).show()
>>> sheet.apply(func, axis=0).show()
'''
assert axis in (0, 1), '`axis` must be 0 or 1'
assert callable(func), '`func` must be a callable object'
cols = self._check_columns_index(cols)
if axis == 0:
subset = self[cols]
try:
func(subset[0].tolist(), *args, **kwrds)
subset = subset.iter_values()
except:
pass
return SeriesSet([func(row, *args, **kwrds) for row in subset])
result = {}
for key in cols:
result[key] = func(self[key], *args, **kwrds)
return SeriesSet(result)
@check_thread_locked
def map(self, func, cols=None, inplace=False):
'''apply(func, col=None, *args, **kwrds)
apply a function to columns or rows
Parameters
----------
func : callable object or dict-like object
col : str, str in list (default='all')
the columns that you expect to process
inplace : True or False (default=0)
update values in current dataset or return new values
Returns
-------
mapped_sheet : SeriesSet
Notes
-----
1. Function may be locked when `inplace` is True and
sheet.locked is False. When you operate the
column which is an Index, it will be locked.
'''
assert inplace in (True, False), '`inplace` must be True or False'
if inplace is False:
return SeriesSet(self)._map(func, cols)
return self._map(func, cols)
def set_index(self, columns):
'''set_index(column) -> None
set a column as an Index for quickly searching
Create an Index for quickly searching the records.
When you have settled down some columns as Indexes,
sheet.query() or sheet.update() will automatically
check your Indexes. If you have the Index, it will
use the Index to quickly select the records. When
you select records with Index, the time cumsulting
is just O(logN).
You must be attention that some of operation
functions will be unavaliable after you have
Indexes. And the others will be a little slower.
Use `sheet.locked` to make sure whether the
sheet is locked or not.
Parameters
----------
columns : str, str in list
the column(s) you want to make index
Returns
-------
None
Examples
--------
See Also
--------
DaPy.SeriesSet.query
DaPy.SeriesSet.update
'''
for col in self._check_columns_index(columns):
error = '%s has been an index already' % col
assert col not in self._sorted_index, error
self._sorted_index[col] = SortedIndex(self._data[col])
def corr(self, method='pearson', col=None):
'''corr(method='pearson', col=None) -> SeriesSet
calculate the correlation among the variables
Calculate the correlation between the variables and
return the result as a n*n matrix.
Parameters
----------
method : str (default='pearson')
the algorithm to calculate the correlation
("pearson", "spearman" and 'kendall' are supported)
col : str or None (default=None)
the columns to calculate
Returns
-------
correlations : SeriesSet
Examples
--------
>>> import DaPy as dp
>>> sheet = dp.SeriesSet({
'A_col': [1, 3, 4, 5, 6, 4, 5, 6, 8],
'B_col': [2, 4, 6, 8, 10, 12, 13, 15, 16],
'C_col': [-2, -3, -4, -5, -4, -7, -8, -10, -11]})
>>> sheet.corr(col=['A', 'B', 'C']).show()
| A | B | C
---+-----------------+----------------+-----------------
A | 1.0 | 0.862775883665 | -0.790569415042
B | 0.862775883665 | 1.0 | -0.95155789511
C | -0.790569415042 | -0.95155789511 | 1.0
'''
from DaPy import corr as corr_
col = self._check_columns_index(col)
frame = [[1.0] * len(col) for i in xrange(len(col))]
for i, current in enumerate(col):
for j, next_ in enumerate(col):
if next_ != current:
coef = corr_(self._data[current],
self._data[next_],
method)
frame[i][j] = coef
frame[j][i] = coef
new_ = SeriesSet(frame, col, nan='')
new_._insert_col(0, col, '')
return new_
def copy(self):
'''copy the current sheet'''
return SeriesSet(self, nan=self._nan)
def count(self, value, col=None, row=None):
'''count(X, col=None, row=None) -> Counter or int
count the frequency of value(s) in a specific area
Count the frequency of values appearence in a specific
area. You should identify an area by columns and rows
indexes. Otherwise, it will check the whole sheet.
Parameters
----------
val : value
anything you want to count in the area
col : None, str, str in list (default=None)
columns you want to count with
None -> all columns will be checked
row : None, int, int in list (default=None)
rows you want to count with
None -> all rows will be checked
Returns
-------
numbers : int / Counter object
If you just have one value, it will return int.
If you have more than one values, it will return a dict.
Examples
--------
>>> sheet = dp.SeriesSet([[1, 2, 3, 4],
[2, None, 3, 4],
[3, 3, None, 5],
[7, 8, 9, 10]])
>>> sheet.show()
C_0 | C_1 | C_2 | C_3
-----+------+------+-----
1 | 2 | 3 | 4
2 | None | 3 | 4
3 | 3 | None | 5
7 | 8 | 9 | 10
>>> sheet.count(3)
4 # 3 totally appears four times in the sheet
>>> sheet.count([3, None]) # None totally appears two times
Counter({3: 4, None: 2})
>>> sheet.count(3, col=0)
1 # 3 totally appears 1 time in the first column
>>> sheet.count(3, col=0, row=[0, 1])
0 # 3 never appears in the first column and the first two rows
Notes
-----
1. Function won't be locked when sheet.locked is False.
'''
if is_value(value):
value = (value,)
assert is_seq(value), 'value must be stored in an iterable'
value = set(value)
col = self._check_columns_index(col)
row = self._check_rows_index(row)
counter = Counter()
for title in col:
sequence = self._data[title]
for val in sequence[row]:
if val in value:
counter[val] += 1
if len(value) == 1:
return counter[tuple(value)[0]]
return counter
def count_nan(self, axis=0):
'''return the frequency of NaN according to `axis`'''
assert axis in (0, 1, None)
if axis == 1:
return self.missing
if axis == 0:
return Series(sum(map(self._isnan, _)) for _ in self.iter_rows())
return sum(self._missing)
def count_values(self, col=None):
'''count_values(col=None) -> Counter
Count the frequency of values for each variable(s).
You could count only a part of your data set with
setting `col` as an iterble inluding the number
of column or variable names.
Parameters
----------
col : None, str or str in list (default=None)
the column you expected to analysis
None -> all columns
Returns
-------
dict : the frequency of elements in each column.
Examples
--------
>>> import DaPy as dp
>>> sheet = dp.SeriesSet([[1, 2, 3, 4],
[2, None, 3, 4],
[3, 3, None, 5],
[7, 8, 9, 10]])
>>> sheet.count_values(col=1)
Counter({8: 1,
2: 1,
3: 1,
None: 1})
>>> sheet.count_values(col=[1, 2])
Counter({3: 3,
None: 2,
8: 1,
9: 1,
2: 1})
Notes
-----
1. Function won't be locked when sheet.locked is False.
'''
col = self._check_columns_index(col)
counter = Counter()
for title in col:
counter.update(self._data[title])
return counter
def query(self, expression, col=None, limit=1000):
'''sheet.query('A_col != 1') -> SeriesSet
Parse a string of python syntax statement and select rows which
match the query. Two algorithms are used in this function. The first
solution, binary select, needed sorted indexes before calling this
function, has a high efficiency with O(logN) time comsumption. On the
other hand, normal linear comparing select, implemented like `where`
function, has a linear efficiency of O(N) speed.
Parameters
----------
expression : str
the statement you want to use to select data,
you can write it like python condition syntax.
col : None, str or list (default=None)
which columns you want to select
limit : int, None (default=1000)
the maximum number of rows you want to select,
this is a good way to speed up selection from
million of rows if you need only 1 of them
in each time.
Return
------
subset : SeriesSet
the selection result according to your statement.
Example
-------
>>> from DaPy.datasets import iris
>>> sheet, info = iris()
>>> sheet.query('5.5 >= sepal length > 5 and sepal width > 4').show()
sepal length | sepal width | petal length | petal width | class
--------------+-------------+--------------+-------------+--------
5.2 | 4.1 | 1.5 | 0.1 | setosa
5.5 | 4.2 | 1.4 | 0.2 | setosa
>>> data.query('sepal length / 2.0 == sepal width').show()
sepal length | sepal width | petal length | petal width | class
--------------+-------------+--------------+-------------+------------
6.4 | 3.2 | 4.5 | 1.5 | versicolor
7.2 | 3.6 | 6.1 | 2.5 | virginica
6.4 | 3.2 | 5.3 | 2.3 | virginica
5.6 | 2.8 | 4.9 | 2.0 | virginica
6.0 | 3.0 | 4.8 | 1.8 | virginica
See Also
--------
DaPy.core.base.Sheet.SeriesSet.set_index
DaPy.core.base.IndexArray.SortedIndex
'''
sub_index, select_col = self._query(expression, col, limit)
if len(sub_index) == 0:
return SeriesSet(None, select_col, nan=self.nan)
return self.iloc(sub_index)[select_col]
def describe(self, level=0):
'''describe(lvel=0, show=True) -> None
summary the information of current sheet
'''
assert level in (0, 1, 2)
from DaPy import describe
info = dict(mins=[], maxs=[], avgs=[], stds=[], skes=[], mode=[],
kurs=[], miss=list(map(str, self._missing)))
for sequence in self.iter_values():
des = describe(Series(filter(lambda x: not self._isnan(x), sequence)))
for arg, val in zip(['mins', 'maxs', 'avgs', 'stds', 'mode', 'skes', 'kurs', ],
[des.Min, des.Max, des.Mean, des.S, des.Mode, des.Skew, des.Kurt]):
if val is None and arg != 'mode':
info[arg].append('-')
elif isinstance(val, float):
if val > 9999999999:
float_template = '%g'
else:
float_template = '%10.' + str(11 - len(str(int(val)))) + 'g'
info[arg].append(float_template % val)
else:
info[arg].append(str(val))
blank_size = [max(len(max(self.columns, key=len)), 5) + 2,
max(len(max(info['miss'], key=len)), 4) + 2,
max(len(max(info['mins'], key=len)), 4) + 2,
max(len(max(info['avgs'], key=len)), 4) + 2,
max(len(max(info['maxs'], key=len)), 4) + 2,
max(len(max(info['stds'], key=len)), 4) + 2,
max(len(max(info['mode'], key=len)), 4) + 2]
# Draw the title line of description
message = '|'.join(['Title'.center(blank_size[0]),
'Miss'.center(blank_size[1]),
'Min'.center(blank_size[2]),
'Mean'.center(blank_size[4]),
'Max'.center(blank_size[3]),
'Std'.center(blank_size[5]),
'Mode'.center(blank_size[6])])
if level >= 1:
blank_size.extend([
max(len(max(info['skes'], key=len)), 4) + 2,
max(len(max(info['kurs'], key=len)), 4) + 1])
message += '|' + '|'.join([
'Skew'.center(blank_size[6]),
'Kurt'.center(blank_size[7])])
message += '\n%s\n' % '+'.join(map(lambda x: '-' * x, blank_size))
# Draw the main table of description
for i, title in enumerate(self._columns):
message += title.center(blank_size[0]) + '|'
message += info['miss'][i].center(blank_size[1]) + '|'
message += info['mins'][i].rjust(blank_size[2] - 1) + ' |'
message += info['avgs'][i].rjust(blank_size[4] - 1) + ' |'
message += info['maxs'][i].rjust(blank_size[3] - 1) + ' |'
message += info['stds'][i].rjust(blank_size[5] - 1) + ' |'
message += info['mode'][i].rjust(blank_size[6] - 1)
if level >= 1:
message += '|' + info['skes'][i].center(blank_size[7]) + '|'
message += info['kurs'][i].center(blank_size[8])
message += '\n'
lenth = 6 + 2 * level + sum(blank_size)
print('1. Structure: DaPy.SeriesSet\n' +\
'2. Dimensions: Lines=%d | Variables=%d\n' % self.shape +\
'3. Miss Value: %d elements\n' % sum(self.missing) +\
'Descriptive Statistics'.center(lenth) + '\n' +\
'=' * lenth + '\n' + message + '=' * lenth)
def drop(self, index=-1, axis=0, inplace=False):
'''remove a column or a row in the sheet
Parameters
----------
index : single value or list-like (default=-1)
Index of column name or index of column or index of rows
axis : 0 or 1
drop index along the row (axis=0) or column (axis=1)
inplace : True or False (default=False)
operate the values in the current sheet or on the copy
Return
------
subset : SeriesSet
if you `inplace` is True, it will return the subset
which drop out the values.
Example
-------
>>> sheet = dp.SeriesSet(range(5))
>>> sheet.drop(0, axis=0, True)
C_0 : <1, 2, 3, 4>
>>> sheet.drop('C_0', axis=1, True)
empty SeriesSet instant
Notes
-----
1. This function has been added into unit test.
'''
assert axis in (0, 1)
if axis == 0:
return self.drop_row(index, inplace)
return self.drop_col(index, inplace)
@check_thread_locked
def drop_col(self, index=-1, inplace=False):
'''drop_col(index=-1, inplace=False) -> SeriesSet
remove the columns according to the index
Parameters
----------
index : int, str or item in list (default=-1)
the columns will be removed
inplace : True / False (default=False)
remove the columns from the current sheet or
remove the columns from a copy of the sheet and
return the copy
Returns
-------
dropped_sheet : SeriesSet
if `inplace` is True, it will return the current sheet,
otherwise, it will return the copy of the sheet.
Examples
--------
'''
if inplace is False:
return SeriesSet(self, nan=self.nan)._drop_col(index)
return self._drop_col(index)
@check_thread_locked
def diff(self, lag=1, cols=None, inplace=False):
if inplace is False:
return SeriesSet(self, nan=self.nan)._diff(lag, cols)
return self._diff(lag, cols)
@check_thread_locked
def drop_row(self, index=-1, inplace=True):
'''drop_row(index=-1, inplace=True) -> SeriesSet
drop out rows according to the index'''
if inplace is False:
return SeriesSet(self, nan=self.nan)._drop_row(index)
return self._drop_row(index)
@check_thread_locked
def dropna(self, axis=0, how='any', inplace=False):
'''dropna(axis=0, how='any', inplace=False)
Drop out all records, which contain miss value, if `axis` is
`0`. Drop out all the variables, which contain miss value,
if `axis` is `1`.
Parameters
----------
axis : 0 or 1 (default=0)
drop out process along axis
0 -> rows: any rows which contain NaN will be droped out.
1 -> cols: any columns which contain NaN will be droped out.
how : 'any', 'all' or float (default='any')
how to delete the records or columns when they appear NaN.
'all' -> each elements of the row or column are NaN, than
we will remove the row or column.
'any' -> If there is at least one NaN in that row or column,
we will remove the row or column.
float -> if the percentage of NaN in that row or column
is greater than the float, we will remove the row
or column.
inplace : True or False (default=False)
opearte on the current sheet or the copy of the sheet
Returns
-------
dropped_sheet : SeriesSet
if `inplace` is True, it will return the current sheet,
otherwise, it will return the copy of the sheet.
Examples
--------
>>> import DaPy as dp
>>> sheet = dp.SeriesSet([[1, 2, 3, 4],
[2, None, None, 4],
[3, 3, None, 5],
[7, 8, 9, 10]],
nan=None)
>>> sheet.dropna(axis=0, how='any').show()
C_0 | C_1 | C_2 | C_3
-----+-----+-----+-----
1 | 2 | 3 | 4
7 | 8 | 9 | 10
>>> sheet.dropna(axis=0, how=0.4).show()
C_0 | C_1 | C_2 | C_3
-----+-----+------+-----
1 | 2 | 3 | 4
3 | 3 | None | 5
7 | 8 | 9 | 10
>>> sheet.dropna(axis=1, how='any').show()
C_0 | C_3
-----+-----
1 | 4
2 | 4
3 | 5
7 | 10
>>> sheet.dropna(axis=1, how=0.4).show()
C_0 | C_1 | C_3
-----+------+-----
1 | 2 | 4
2 | None | 4
3 | 3 | 5
7 | 8 | 10
'''
assert axis in (0, 1), 'axis must be 1 or 0.'
err = '`how` must be "any", "all" or float between 0 and 1'
assert how in ('any', 'all') or 1 > how > 0, err
if axis == 1:
pop_ind, lenth = [], float(self.shape.Ln)
for i, value in enumerate(self._missing):
if how == 'any' and value > 0:
pop_ind.append(self._columns[i])
elif value / lenth > how:
pop_ind.append(self._columns[i])
elif how == 'all' and value == lenth:
pop_ind.append(self._columns[i])
return self.drop_col(pop_ind, inplace)
# if axis == 0:
pop_ind, lenth = [], float(self.shape.Col)
for i, row in enumerate(self.iter_rows()):
num = count_nan(self._isnan, row)
if how == 'any':
if num > 0:
pop_ind.append(i)
elif num / lenth > how:
pop_ind.append(i)
elif how == 'all':
if num == lenth:
pop_ind.append(i)
return self.drop_row(pop_ind, inplace)
def drop_duplicates(self, col=None, keep='first', inplace=False):
'''drop_duplicates(col=None, keep='first', inplace=False) -> SeriesSet
'''
assert self.locked, LOCK_ERROR
assert keep in ('first', 'last', False)
pop_col = self._check_columns_index(col)
drop_ind, drop_symbol = [], DUPLICATE_KEEP[keep]
droped_table = self._group_index_by_column_value(pop_col) # O(n)
for values in droped_table.values(): # O(n)
if len(values) != 1:
drop_ind.extend(values[drop_symbol])
return self.drop_row(drop_ind, inplace) # O(k*lnk + n)
@check_thread_locked
def extend(self, item, inplace=False):
'''extend the current SeriesSet with records in set.
Examples
--------
>>> import DaPy as dp
>>> data1 = dp.SeriesSet(
[[11, 11],
[21, 21],
[31, 31],
[41, 41]],
['C1', 'C2']), 'Table1')
>>> data2 = dp.SeriesSet(
[[21, 21],
[22, 22],
[23, 23],
[24, 24]],
['C2', 'C3']), 'Table2')
>>> data1.extend(data2)
C1 | C2 | C3
-----+----+------
11 | 11 | nan
21 | 21 | nan
31 | 31 | nan
41 | 41 | nan
nan | 21 | 21
nan | 22 | 22
nan | 23 | 23
nan | 24 | 24
Notes
-----
1. This function has been added into unit test.
'''
if isinstance(item, SeriesSet) is False:
try:
columns = item.columns if hasattr(item, 'columns') else self.columns
item = self._extend(SeriesSet(item, columns))
except:
raise TypeError('could not extend a single value only.')
if inplace is False:
return SeriesSet(self)._extend(item)
return self._extend(item)
@check_thread_locked
def fillna(self, fill_with=None, col=None, method=None, limit=None):
'''fill nan in the dataset
Parameters
----------
fill_with : value, dict in valu (default=None)
the value used to fill with
cols : str or str in list (default=None)
the columns would be operated, None means the whole dataset
method : str (default=None)
which method you expect to use, if this keyword is not None,
`fill_with` keyword will be failed to use. The data which use to
establish the model are located around the missing value and the
number of those data are auto-adapt.
`linear` : establish a linear model
limit : int (default=None)
the maximum number of missing values to fill with, operate all
missing value use None.
Return
------
self
Example
-------
>>> data = dp.SeriesSet({'A': [dp.nan, 1, 2, 3, dp.nan, dp.nan, 6]},
nan=dp.nan)
>>> data.fillna(method='linear')
>>> data
A: <0.0, 1, 2, 3, 4.0, 5.0, 6>
'''
return self._fillna(fill_with, col, method, limit)
def flatten(self, axis=0):
'''flatten 2-dimentions table into 1-dimention Series'''
return Series(self._flatten(axis))
@classmethod
def from_file(cls, addr, **kwrd):
'''read dataset from .txt or .csv file.
Parameters
----------
addr : str
address of source file.
first_line : int (default=1)
the first line with data.
miss_symbol : str or str in list (default=['?', '??', '', ' ', 'NA', 'None'])
the miss value symbol in csv file.
nan : str (default=float('nan'))
the symbol of missing value in current sheet
title_line : int (default=0)
the line with title, rules design as follow:
-1 -> there is no title inside;
>=0 -> the titleline.
sep : str (default=",")
the delimiter symbol inside.
dtypes : Type name or dict of columns (default=None):
use specific data types for parsing each column
int -> transfer any possible values into int
float -> transfer any possible values into float
str -> keep all values in str type
datetime -> transfer any possible values into datetime-object
bool -> transfer any possible values into bool
'''
nan = kwrd.get('nan', NaN)
sheet = cls(nan=nan)
first_line = kwrd.get('first_line', 1)
title_line = kwrd.get('title_line', first_line - 1)
columns = list(kwrd.get('columns', []))
sep = kwrd.get('sep', ',')
dtypes = kwrd.get('dtypes', [])
if is_str(dtypes):
dtypes = [dtypes]
miss_symbol = kwrd.get('miss_symbol', set(['nan', '?', '??', '', ' ', 'NA', 'None']))
if is_value(miss_symbol):
miss_symbol = [miss_symbol]
if isinstance(miss_symbol, set) is False:
miss_symbol = set(miss_symbol)
miss_symbol.add(None)
split, strip = str.split, str.strip
if kwrd.get('careful_cut', None):
pattern = re_compile(sep + '(?=(?:[^"]*"[^"]*")*[^"]*$)')
split = pattern.split
param, data, miss = {'mode': 'rU'}, (), ()
if PYTHON3:
param['encoding'] = kwrd.get('encoding', None)
param['file'] = addr
param['newline'] = kwrd.get('newline', None)
if PYTHON2:
param['name'] = addr
assert first_line > title_line, '`first_line` must be larger than `title_line`'
assert all(map(is_str, columns)), 'column names must be `'
with open(**param) as file_:
# skip the rows which are unexpected to read
for i in xrange(first_line):
line = file_.readline()
if i == title_line:
# setup the title line
columns = tuple(map(lambda x: strip(x), split(line, sep)))
# begin to load data
for i, row in enumerate(file_):
for mis, seq, transfer, val in zip_longest(miss, data, dtypes, split(strip(row), sep)):
# iter value
try:
if val in miss_symbol:
seq.append(nan)
mis.append(1)
else:
seq.append(transfer(val.encode('utf-8')))
except ValueError:# different types of data in the same variable
seq.append(auto_str2value(val))
except Exception as e: # we found a new variable
mis = []
miss += (mis,)
if val in miss_symbol:
val = nan
mis.append(1)
else:
val = auto_str2value(val, transfer)
type_name = str(val.__class__).split()[1][1:-2].split('.')[0]
dtypes.append(fast_str2value[type_name])
if not data:
data += (Series([val]),)
else:
missed = len(data[0]) - 1
mis.append(missed)
data += (Series(chain(repeat(nan, missed), [val])),)
sheet._dim = SHEET_DIM(len(data[0]), len(data))
sheet._init_col_name(columns)
for i, (missing, seq, col) in enumerate(zip(miss, data, sheet.columns)):
add_space = sheet.shape.Ln - len(seq)
seq.extend(repeat(sheet.nan, add_space))
sheet._missing.append(add_space + sum(missing))
sheet._data[col] = seq
return sheet
def get(self, key, default=None):
'''get(key, default=None) -> row or Series
select column or row from the sheet,
return `default` if `key` is not a column name
'''
return self._get(key, default)
def get_best_features(self, method='variance', X=None, Y=None, top_k=1):
'''get_best_features(method='variance', X=None, Y=None, top_k=1) -> SeriesSet
Select K features which are the most important to the variable `Y`
'''
return self._get_best_features(method, X, Y, top_k)
def get_categories(self, cols, cut_points, group_name,
boundary=(False, True), inplace=False):
'''transfer numerical variables into categorical variable'''
if inplace is False:
return SeriesSet(self, nan=self.nan)._get_categories(
cols, cut_points, group_name, boundary)
return self._get_categories(cols, cut_points, group_name, boundary)
def get_date_label(self, cols, daytime=True,
weekend=True, season=True, inplace=False):
'''transfer a datetime object into categorical variables'''
cols = self._check_columns_index(cols)
if inplace is False:
self = SeriesSet(nan=self.nan)
def dummy_date(col_name):
sequence = copy(self.data[col_name])
for i, value in enumerate(sequence):
if isinstance(value, datetime) is False:
sequence[i] = str2date(str(value))
date_sheet = SeriesSet(None, ['month', 'hour', 'week'])
for row in sequence:
date_sheet.append_row([row.month, row.hour, row.weekday()])
return date_sheet
for col in cols:
date = dummy_date(col)
self._get_date_label(date, col, daytime, weekend, season)
return self
def get_dummies(self, cols=None, value=1, inplace=False):
'''Convert categorical variable into multiple binary variables
Parameters
----------
cols : str or str in list (default=None)
the columns would be operated, None means the whole dataset
value : value-type (default=1)
the value which will be used as a mark in the return object
inplace : True or False (default=False)
operate the values in the current sheet or on the copy
Examples
--------
>>> import DaPy as dp
>>> sheet = dp.SeriesSet([
['A', 2],
['B', 3],
['A', 3],
['C', 1],
['D', 4],
['C', 1]],
['alpha', 'num'])
>>> sheet.get_dummies(cols='alpha').show()
alpha | num | alpha_A | alpha_C | alpha_B | alpha_D
-------+-----+---------+---------+---------+---------
A | 2 | 1 | 0 | 0 | 0
B | 3 | 0 | 0 | 1 | 0
A | 3 | 1 | 0 | 0 | 0
C | 1 | 0 | 1 | 0 | 0
D | 4 | 0 | 0 | 0 | 1
C | 1 | 0 | 1 | 0 | 0
'''
if inplace is False:
return SeriesSet(self, nan=self.nan)._get_dummies(cols, value)
return self._get_dummies(cols, value)
def get_interactions(self, n_power=2, cols=None, inplace=False):
'''get_interactions(n_var=3, cols=None, inplace=False) -> SeriesSet
create new variables by multipling each other
Getting interactions of variables is a common operation
in Feature Engineering. This function will help you
achieve it easily.
Parameters
----------
n_power : int (default=2)
the number of features to create interactions.
For example, you have variables A and B. You want
to create new variable with A * A * B, you should
set n_var=3.
cols : str, str in list (default=None)
the features to create interactions.
inplace : True / False (default=False)
save the new_features in current sheet or not
Returns
-------
new_features : SeriesSet
Examples
--------
>>> sheet = SeriesSet({'A': [1, 1, 1, float('nan')],
'B': [2, 2, 2, 2],
'C': [3, 3, 3, 3]})
>>> sheet.get_interactions(2).show()
B*C | A^2 | B^2 | C^2 | A*B | A*C
-----+-----+-----+-----+-----+-----
6 | 1 | 4 | 9 | 2 | 3
6 | 1 | 4 | 9 | 2 | 3
6 | 1 | 4 | 9 | 2 | 3
6 | nan | 4 | 9 | nan | nan
>>> sheet = SeriesSet({'A': [1, 1, 1, 1],
'B': [2, 2, 2, 2],})
>>> sheet.get_interactions(3).show()
B^3 | A*B^2 | A^3 | A^2*B
-----+-------+-----+-------
8 | 4 | 1 | 2
8 | 4 | 1 | 2
8 | 4 | 1 | 2
8 | 4 | 1 | 2
'''
new_features = self._get_interactions(SeriesSet(nan=self.nan))
if inplace is False:
return new_features
return self.join(new_features, inplace=True)
def get_ranks(self, cols=None, duplicate='mean', inplace=False):
'''get_ranks(cols=None, duplicate='mean', inplace=False) -> SeriesSet
get the ranks of each row in each column
Parameters
----------
cols : str, str in list (default=None)
duplicate : 'mean', 'first' (default='mean')
how to rank the records which obtain the same value
inplace : True / False (default=False)
restore the ranks in a new SeriesSet or not
Returns
-------
ranks : SeriesSet
Examples
--------
>>> sheet = SeriesSet({'A': [2, 2, 1, 1],
'B': [2, 7, 5, 2],})
>>> sheet.get_ranks(inplace=True).show()
A | B | A_rank | B_rank
---+---+--------+--------
2 | 2 | 3.5 | 1.5
2 | 7 | 3.5 | 4
1 | 5 | 1.5 | 3
1 | 2 | 1.5 | 1.5
'''
ranks = self._get_ranks(SeriesSet(nan=self.nan), cols, duplicate)
if inplace is False:
return ranks
return self.join(ranks, inplace=True)
def get_nan_instrument(self, cols=None, inplace=False):
'''create instrument variable for determining whether a variable is miss or not'''
instruments = self._get_nan_instrument(SeriesSet(nan=self.nan), cols)
if inplace is False:
return instruments
return self.join(instruments, inplace=True)
def get_numeric_label(self, cols=None, inplace=False):
'''encode string values into numerical values'''
to_return = self if inplace is True else SeriesSet(nan=self.nan)
return self._get_numeric_label(to_return, cols)
def groupby(self, keys, func=None, apply_col=None):
'''groupby(keys, func=None, apply_col=None)
It will return the result of function of each groupby object when
you pass a callable object in `func`. Otherwise, it will return
each groupby subsheet in a dict.
Parameters
----------
keys : str, str in list
columns that will be seem as category variable
func : None or function (default=None)
map this function to each group by subsheet
apply_col : str, str in list (default=None)
The columns will be used by the function,
default means all columns will be used.
Returns
-------
groupby : SeriesSet or dict
if `func` is not None, it will be SeriesSet.
Examples
--------
>>> from DaPy.datasets import iris
>>> from DaPy import sum
>>> sheet = iris()[0]
- read() in 0.001s.
>>> sheet.groupby('class').show(3)
- groupby() in 0.000s.
sheet:('virginica',)
====================
sepal length | sepal width | petal length | petal width | class
--------------+-------------+--------------+-------------+-----------
6.3 | 3.3 | 6.0 | 2.5 | virginica
5.8 | 2.7 | 5.1 | 1.9 | virginica
7.1 | 3.0 | 5.9 | 2.1 | virginica
.. Omit 44 Ln ..
6.5 | 3.0 | 5.2 | 2.0 | virginica
6.2 | 3.4 | 5.4 | 2.3 | virginica
5.9 | 3.0
gitextract_ackf5hh1/ ├── .github/ │ └── ISSUE_TEMPLATE/ │ ├── bug_report.md │ └── feature_request.md ├── DaPy/ │ ├── __init__.py │ ├── core/ │ │ ├── DataSet.py │ │ ├── __init__.py │ │ ├── base/ │ │ │ ├── BaseSheet.py │ │ │ ├── DapyObject.py │ │ │ ├── IndexArray.py │ │ │ ├── LinkedArray.py │ │ │ ├── Matrix.py │ │ │ ├── Series.py │ │ │ ├── Sheet.py │ │ │ ├── Views/ │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── absents/ │ │ │ │ └── Frame.py │ │ │ ├── constant.py │ │ │ ├── row.py │ │ │ └── utils/ │ │ │ ├── __init__.py │ │ │ ├── py_string_transfer.py │ │ │ ├── string_transfer.pyd │ │ │ ├── utils_2to3.py │ │ │ ├── utils_grammar_parser.py │ │ │ ├── utils_isfunc.py │ │ │ ├── utils_join_table.py │ │ │ ├── utils_regression.py │ │ │ ├── utils_str_patterns.py │ │ │ ├── utils_str_transfer.py │ │ │ └── utils_toolkits.py │ │ ├── io.py │ │ └── sqlparser.py │ ├── datasets/ │ │ ├── __init__.py │ │ ├── adult/ │ │ │ ├── adult.csv │ │ │ └── data.csv │ │ ├── example/ │ │ │ └── sample.csv │ │ ├── iris/ │ │ │ ├── data.csv │ │ │ └── info.txt │ │ ├── lenses/ │ │ │ └── data.txt │ │ └── wine/ │ │ ├── data.csv │ │ └── info.txt │ ├── doc/ │ │ ├── Quick Start.md │ │ ├── Quick Start_Chinese.md │ │ ├── README.md │ │ └── README_Chinese.md │ ├── io.py │ ├── matlib.py │ ├── methods/ │ │ ├── __init__.py │ │ ├── classifiers/ │ │ │ ├── __init__.py │ │ │ ├── classifier.py │ │ │ ├── linear_models.py │ │ │ ├── mlp.py │ │ │ └── tree.py │ │ ├── core/ │ │ │ ├── __init__.py │ │ │ ├── base/ │ │ │ │ ├── __init__.py │ │ │ │ ├── activators.py │ │ │ │ ├── layers.py │ │ │ │ ├── models.py │ │ │ │ └── utils.py │ │ │ ├── bp_model.py │ │ │ ├── linear_model.py │ │ │ ├── multilayer_perceptron.py │ │ │ ├── pagerank.py │ │ │ └── tfidf.py │ │ ├── evaluator.py │ │ ├── regressors/ │ │ │ ├── __init__.py │ │ │ └── lr.py │ │ ├── statistic/ │ │ │ ├── __init__.py │ │ │ ├── compare_position.py │ │ │ ├── compare_scaler.py │ │ │ ├── discriminant_analysis.py │ │ │ ├── distribution.py │ │ │ └── kMeans.py │ │ └── utils.py │ ├── operation.py │ └── tests/ │ ├── __init__.py │ ├── scripts/ │ │ ├── performance.py │ │ ├── test_lr.py │ │ ├── test_matrix.py │ │ ├── test_merge.py │ │ └── test_methods.py │ ├── test_CoreBaseIndexArray.py │ ├── test_CoreBaseSeries.py │ ├── test_CoreBaseSheet.py │ ├── test_CoreBaseTools.py │ └── test_methods.py ├── README.md ├── README_Chinese.md ├── _config.yml ├── clib/ │ ├── build/ │ │ └── temp.win-amd64-3.6/ │ │ └── Release/ │ │ ├── string_transfer.cp36-win_amd64.exp │ │ ├── string_transfer.cp36-win_amd64.lib │ │ └── string_transfer.obj │ ├── io.c │ ├── io.html │ ├── io.pyx │ ├── math.c │ ├── math.html │ ├── math.pyx │ ├── setup.py │ ├── string_transfer.c │ ├── string_transfer.html │ └── string_transfer.pyx ├── doc/ │ ├── DaPy Framework.xlsx │ ├── Guide Book/ │ │ ├── Chinese/ │ │ │ ├── README.md │ │ │ └── 快速开始.md │ │ ├── English/ │ │ │ ├── Features.md │ │ │ ├── Introduction.md │ │ │ ├── Performance Test for DaPy.md │ │ │ └── Quick Start.md │ │ └── README.md │ ├── Quick Start/ │ │ ├── Chinese.md │ │ ├── English.md │ │ └── get-start.py │ ├── Reading/ │ │ ├── DaPy - Introduction.txt │ │ ├── DaPy - Smooth Data Mining Experience.md │ │ ├── DaPy - 丝滑般实现数据分析.md │ │ └── DaPy - 简介.md │ ├── homepage/ │ │ ├── License.md │ │ ├── TODO.md │ │ └── Version-Log.md │ ├── info.txt │ └── material/ │ ├── DaPy.ai │ └── DaPy.psd └── setup.py
SYMBOL INDEX (1704 symbols across 57 files)
FILE: DaPy/__init__.py
function _unittests (line 61) | def _unittests():
FILE: DaPy/core/DataSet.py
function timer (line 20) | def timer(func):
function operater (line 31) | def operater(callfunc):
class DataSet (line 48) | class DataSet(object):
method __init__ (line 98) | def __init__(self, obj=None, sheet='sheet0', log=SHOW_LOG):
method data (line 145) | def data(self):
method columns (line 151) | def columns(self):
method logging (line 170) | def logging(self):
method logging (line 174) | def logging(self, value):
method level (line 181) | def level(self):
method columns (line 185) | def columns(self, value):
method sheets (line 191) | def sheets(self):
method sheets (line 195) | def sheets(self, other):
method shape (line 210) | def shape(self):
method info (line 220) | def info(self):
method __getattr__ (line 230) | def __getattr__(self, name):
method _check_col_ind_str (line 247) | def _check_col_ind_str(self, ind):
method _check_col_ind_int (line 251) | def _check_col_ind_int(self, ind):
method _check_sheet_new_name (line 257) | def _check_sheet_new_name(self, new_name):
method _check_sheet_index_slice (line 266) | def _check_sheet_index_slice(self, i, j):
method _check_sheet_index (line 276) | def _check_sheet_index(self, sheet):
method __getstate__ (line 293) | def __getstate__(self):
method __setstate__ (line 300) | def __setstate__(self, arg):
method __contains__ (line 305) | def __contains__(self, e):
method __repr__ (line 314) | def __repr__(self):
method __len__ (line 325) | def __len__(self):
method __getitem__ (line 332) | def __getitem__(self, key):
method __getslice__ (line 339) | def __getslice__(self, i, j):
method __setitem__ (line 342) | def __setitem__(self, key, val):
method __delslice__ (line 373) | def __delslice__(self, start, stop):
method __delitem__ (line 382) | def __delitem__(self, key):
method __iter__ (line 398) | def __iter__(self):
method __reversed__ (line 406) | def __reversed__(self):
method _add (line 412) | def _add(self, item, name):
method add (line 427) | def add(self, items, names=None):
method apply (line 473) | def apply(self, func, col=None, axis=0, *args, **kwrds):
method append_row (line 478) | def append_row(self, item):
method append_col (line 483) | def append_col(self, series, variable_name=None):
method corr (line 488) | def corr(self, method='pearson', col=None):
method count (line 493) | def count(self, value, col=None, row=None):
method copy (line 498) | def copy(self):
method count_values (line 503) | def count_values(self, col=None):
method set_index (line 508) | def set_index(self, column):
method get (line 513) | def get(self, key, default):
method get_tables (line 516) | def get_tables(self, cols=None):
method get_best_features (line 524) | def get_best_features(self, method='variance', X=None, Y=None, top_k=1...
method get_categories (line 529) | def get_categories(self, cols, cut_points, group_name, boundary=(False...
method get_date_label (line 534) | def get_date_label(self, cols, daytime=True,
method get_interactions (line 540) | def get_interactions(self, n_power=3, cols=None, inplace=False):
method get_ranks (line 545) | def get_ranks(self, cols=None, duplicate='mean', inplace=False):
method get_dummies (line 550) | def get_dummies(self, col=None, value=1, inplace=False):
method get_nan_instrument (line 555) | def get_nan_instrument(cols=None, inplace=False):
method get_numeric_label (line 560) | def get_numeric_label(self, cols=None, inplace=False):
method groupby (line 565) | def groupby(self, keys, func=None, apply_col=None, unapply_col=None):
method insert_row (line 570) | def insert_row(self, index, item):
method insert_col (line 575) | def insert_col(self, index, series, variable_name=None):
method dropna (line 580) | def dropna(self, axis=0, how='any', inplace=False):
method select (line 585) | def select(self, where, col=None, limit=1000):
method pop (line 590) | def pop(self, index=-1, aixs=0):
method pop_row (line 595) | def pop_row(self, index=-1):
method pop_col (line 600) | def pop_col(self, col='all'):
method query (line 605) | def query(self, expression, col=None, limit=1000):
method extend (line 610) | def extend(self, other):
method join (line 615) | def join(self, other):
method normalized (line 620) | def normalized(self, process='NORMAL', col=None, **kwrds):
method map (line 625) | def map(self, func, cols=None, inplace=False):
method merge (line 630) | def merge(self, other, self_key=0, other_key=0, keep_key=True, keep_sa...
method drop (line 635) | def drop(self, index=-1, axis=0, inplace=False):
method drop_row (line 640) | def drop_row(self, index=-1, axis=0, inplace=False):
method drop_col (line 645) | def drop_col(self, index=-1, axis=0, inplace=False):
method fillna (line 650) | def fillna(self, fill_with=None, col=None, method=None, limit=None):
method read (line 654) | def read(self, addr, dtype='col', **kwrd):
method reshape (line 811) | def reshape(self, nshape):
method reverse (line 815) | def reverse(self, axis='sheet'):
method replace (line 850) | def replace(self, old, new, col=None, regex=False, sheet=None):
method shuffle (line 855) | def shuffle(self):
method sort (line 860) | def sort(self, *orders):
method save (line 864) | def save(self, addr, **kwrds):
method todict (line 977) | def todict(self):
method tocol (line 981) | def tocol(self):
method tomat (line 1002) | def tomat(self):
method tolist (line 1017) | def tolist(self):
method toarray (line 1022) | def toarray(self):
method show (line 1025) | def show(self, max_lines=None, max_display=75, max_col_size=25, multi_...
FILE: DaPy/core/base/BaseSheet.py
function where_by_index_combine (line 26) | def where_by_index_combine(rows, symbols):
class BaseSheet (line 37) | class BaseSheet(Object):
method __init__ (line 60) | def __init__(self, obj=None, columns=None, nan=NaN):
method data (line 109) | def data(self):
method shape (line 114) | def shape(self):
method columns (line 119) | def columns(self):
method columns (line 124) | def columns(self, item):
method nan (line 140) | def nan(self):
method nan (line 145) | def nan(self, item):
method locked (line 157) | def locked(self):
method __repr__ (line 164) | def __repr__(self):
method __getattr__ (line 191) | def __getattr__(self, name):
method __len__ (line 197) | def __len__(self):
method __compare_value__ (line 201) | def __compare_value__(self, val, empty, symbol):
method __contains__ (line 207) | def __contains__(self, cmp_):
method __delitem__ (line 230) | def __delitem__(self, key):
method __delslice__ (line 250) | def __delslice__(self, key):
method __getslice__ (line 257) | def __getslice__(self, start, stop, step=1):
method __getstate__ (line 265) | def __getstate__(self):
method __setstate__ (line 271) | def __setstate__(self, read_dict):
method __getitem__ (line 281) | def __getitem__(self, interval):
method __iter__ (line 302) | def __iter__(self):
method __reversed__ (line 306) | def __reversed__(self):
method __setitem__ (line 310) | def __setitem__(self, key, value):
method _analyze_keywords (line 354) | def _analyze_keywords(self, key):
method _accumulate (line 370) | def _accumulate(self, func=None, cols=None, skipna=True):
method _add_row (line 378) | def _add_row(self, row):
method _append_row (line 414) | def _append_row(self, row):
method _append_col (line 421) | def _append_col(self, series, variable_name=None):
method _map (line 431) | def _map(self, func, cols):
method _apply (line 441) | def _apply(self, func, col, *args, **kwrds):
method _arrange_by_index (line 454) | def _arrange_by_index(self, self_new_index=None):
method _check_mixture_tuple (line 459) | def _check_mixture_tuple(self, key):
method _check_sequence (line 474) | def _check_sequence(self, series, size):
method _check_col_new_name (line 491) | def _check_col_new_name(self, new_name):
method _check_slice (line 500) | def _check_slice(self, slc):
method _check_slice_row (line 515) | def _check_slice_row(self, start, stop):
method _check_slice_col (line 532) | def _check_slice_col(self, start, stop):
method _check_operation_key (line 548) | def _check_operation_key(self, keys):
method _check_columns_index (line 552) | def _check_columns_index(self, col):
method _check_rows_index (line 575) | def _check_rows_index(self, row):
method _diff (line 594) | def _diff(self, lag=1, cols=None):
method _drop_col (line 602) | def _drop_col(self, index):
method _drop_row (line 617) | def _drop_row(self, index):
method _extend (line 626) | def _extend(self, item):
method _fillna (line 648) | def _fillna(self, fill_with=None, col=None, method=None, limit=None):
method _fillna_value (line 671) | def _fillna_value(self, fill_with, col, _isnan, all_limit):
method _fillna_simple_function (line 690) | def _fillna_simple_function(self, col, _isnan, all_limit, func):
method _flatten (line 751) | def _flatten(self, axis):
method _getitem_by_tuple_subcol (line 757) | def _getitem_by_tuple_subcol(self, key, subset):
method _getitem_by_tuple_subrow (line 775) | def _getitem_by_tuple_subrow(self, int_args, slc_args, subset):
method _getitem_by_tuple (line 783) | def _getitem_by_tuple(self, key, subset):
method _group_index_by_column_value (line 799) | def _group_index_by_column_value(self, columns, engine=list):
method _getslice_col (line 805) | def _getslice_col(self, i, j):
method _getslice_ln (line 811) | def _getslice_ln(self, i, j, k):
method _get (line 820) | def _get(self, key, default=None):
method _get_best_features (line 831) | def _get_best_features(self, method, X, Y, top_k):
method _get_categories (line 850) | def _get_categories(self, cols, cut_points, group_name, boundary):
method _get_date_label (line 860) | def _get_date_label(self, date, col, day, weekend, season):
method _get_dummies (line 885) | def _get_dummies(self, cols, value=1):
method _get_interactions (line 895) | def _get_interactions(self, new_features, n_power, cols):
method _get_nan_instrument (line 930) | def _get_nan_instrument(self, instruments, cols):
method _get_ranks (line 937) | def _get_ranks(self, ranks, cols, duplicate):
method _get_numeric_label (line 946) | def _get_numeric_label(self, to_return, cols):
method _init_col_name (line 954) | def _init_col_name(self, columns):
method _init_nan_func (line 975) | def _init_nan_func(self):
method _init_col (line 981) | def _init_col(self, series, columns):
method _init_dict (line 997) | def _init_dict(self, series, columns):
method _init_frame (line 1017) | def _init_frame(self, series, columns):
method _init_like_seq (line 1033) | def _init_like_seq(self, series, columns):
method _init_like_table (line 1046) | def _init_like_table(self, series, columns):
method _init_like_iter (line 1062) | def _init_like_iter(self, series, columns):
method _iloc (line 1079) | def _iloc(self, subset, indexs):
method _iter_groupby (line 1091) | def _iter_groupby(self, keys, func=None, apply_col=None):
method _insert_row (line 1120) | def _insert_row(self, index, new_row):
method _insert_col (line 1126) | def _insert_col(self, index, new_series, new_name):
method _join (line 1136) | def _join(self, other):
method _match_column_from_str (line 1151) | def _match_column_from_str(self, statement):
method make_table (line 1158) | def make_table(cls, shape, fill_with=None, nan=NaN):
method _normalized (line 1167) | def _normalized(self, process, cols):
method _pop_row (line 1204) | def _pop_row(self, pop_data, index=-1):
method _pop_col (line 1215) | def _pop_col(self, pop_data, col):
method _query (line 1230) | def _query(self, expression, col, limit):
method _quickly_append_col (line 1244) | def _quickly_append_col(self, col, seq, miss, pos=None):
method _replace (line 1255) | def _replace(self, old, new, col, regex):
method _reverse (line 1287) | def _reverse(self, axis=0):
method _setitem_slice_row (line 1297) | def _setitem_slice_row(self, start, stop, value):
method _setitem_slice_col (line 1306) | def _setitem_slice_col(self, start, stop, value):
method _setitem_cell (line 1323) | def _setitem_cell(self, ln, col, val):
method _shuffle (line 1339) | def _shuffle(self):
method _show (line 1344) | def _show(self, col_size, rows, omit_line, max_len, omit):
method _sort (line 1357) | def _sort(self, subset, *orderby):
method _trans_where (line 1382) | def _trans_where(self, where, axis=0):
method _update (line 1407) | def _update(self, where, **set_values):
method _where_by_index_bigcombine (line 1420) | def _where_by_index_bigcombine(self, combines, string):
method _where_by_index_subcombine (line 1427) | def _where_by_index_subcombine(self, subcombine, string):
method _where_by_index_simple (line 1433) | def _where_by_index_simple(self, column, string):
method _where_by_index (line 1470) | def _where_by_index(self, string):
method _where_by_rows (line 1505) | def _where_by_rows(self, where, limit):
method todict (line 1527) | def todict(self):
method tolist (line 1530) | def tolist(self):
method toarray (line 1534) | def toarray(self):
FILE: DaPy/core/base/DapyObject.py
class Object (line 5) | class Object(object):
method __init__ (line 7) | def __init__(self):
method thread_safety (line 11) | def thread_safety(self):
method thread_safety (line 17) | def thread_safety(self, mode):
method THREAD_LOCK (line 26) | def THREAD_LOCK(self):
function check_thread_locked (line 30) | def check_thread_locked(func):
FILE: DaPy/core/base/IndexArray.py
class SortedIndex (line 8) | class SortedIndex(Sequence):
method __init__ (line 9) | def __init__(self, array=(), index=()):
method __getitem__ (line 21) | def __getitem__(self, indices):
method __len__ (line 26) | def __len__(self):
method __repr__ (line 29) | def __repr__(self):
method append (line 38) | def append(self, value):
method between (line 46) | def between(self, low, high, boundary=(True, True), return_value=False):
method count (line 95) | def count(self, value):
method equal (line 99) | def equal(self, value):
method insert (line 106) | def insert(self, value, index):
method _get_item_index (line 112) | def _get_item_index(self, value):
method index (line 124) | def index(self, value):
method lower (line 161) | def lower(self, value, include_equal=True):
method remove (line 184) | def remove(self, value):
method upper (line 216) | def upper(self, value, include_equal=True):
method unequal (line 239) | def unequal(self, value):
FILE: DaPy/core/base/LinkedArray.py
class intLinkedNode (line 3) | class intLinkedNode(Structure):
method __init__ (line 21) | def __init__(self, next=None, val=None):
class intLinkedNode (line 20) | class intLinkedNode(object):
method __init__ (line 21) | def __init__(self, next=None, val=None):
function _append_left (line 25) | def _append_left(link, new_val):
function _show_values (line 28) | def _show_values(link):
FILE: DaPy/core/base/Matrix.py
class Matrix (line 15) | class Matrix(object):
method __init__ (line 19) | def __init__(self, table=None):
method src (line 35) | def src(self):
method shape (line 39) | def shape(self):
method T (line 43) | def T(self):
method I (line 50) | def I(self):
method D (line 76) | def D(self):
method __repr__ (line 83) | def __repr__(self):
method __getstate__ (line 124) | def __getstate__(self):
method __setstate__ (line 129) | def __setstate__(self, dict):
method __contains__ (line 133) | def __contains__(self, e):
method __len__ (line 140) | def __len__(self):
method __eq__ (line 143) | def __eq__(self, other):
method __getitem__ (line 161) | def __getitem__(self, pos):
method __setitem__ (line 169) | def __setitem__(self, pos, value):
method __iter__ (line 188) | def __iter__(self):
method __int__ (line 192) | def __int__(self):
method __ne__ (line 198) | def __ne__(self, other):
method __neg__ (line 203) | def __neg__(self):
method __pos__ (line 211) | def __pos__(self):
method __sum__ (line 219) | def __sum__(self, other):
method __abs__ (line 222) | def __abs__(self):
method __add__ (line 230) | def __add__(self, other):
method __radd__ (line 266) | def __radd__(self, other):
method __sub__ (line 269) | def __sub__(self, other):
method __rsub__ (line 319) | def __rsub__(self, other):
method __mul__ (line 368) | def __mul__(self, other):
method __rmul__ (line 418) | def __rmul__(self, other):
method __div__ (line 421) | def __div__(self, other):
method __truediv__ (line 473) | def __truediv__(self, other):
method __rdiv__ (line 476) | def __rdiv__(self, other):
method __rtruediv__ (line 527) | def __rtruediv__(self, other):
method __pow__ (line 530) | def __pow__(self, other):
method _get_cofactor (line 553) | def _get_cofactor(self, i, j):
method _init_unknow_type (line 557) | def _init_unknow_type(self, table):
method _init_src_shape (line 567) | def _init_src_shape(cls, src, judge_shape=True):
method argmax (line 573) | def argmax(self, axis=None):
method diagonal (line 592) | def diagonal(self):
method dot (line 595) | def dot(self, other):
method make (line 612) | def make(cls, Ln, Col, element=0):
method make_random (line 621) | def make_random(cls, Ln, Col, type_int=False):
method make_eye (line 639) | def make_eye(cls, size, value=None):
method from_text (line 654) | def from_text(cls, addr, **kward):
method reshape (line 674) | def reshape(self, new_shape):
method tolist (line 688) | def tolist(self):
FILE: DaPy/core/base/Series.py
function quickly_apply (line 29) | def quickly_apply(operation, left, right):
class Series (line 35) | class Series(list):
method __init__ (line 36) | def __init__(self, array=[]):
method data (line 42) | def data(self):
method shape (line 46) | def shape(self):
method __repr__ (line 49) | def __repr__(self):
method __eq__ (line 56) | def __eq__(self, other):
method __gt__ (line 60) | def __gt__(self, other):
method __ge__ (line 64) | def __ge__(self, other):
method __lt__ (line 68) | def __lt__(self, other):
method __le__ (line 72) | def __le__(self, other):
method __setitem__ (line 76) | def __setitem__(self, key, val):
method __getitem__ (line 113) | def __getitem__(self, key):
method __delitem__ (line 163) | def __delitem__(self, key):
method __getslice__ (line 204) | def __getslice__(self, start, stop):
method _check_operate_value (line 207) | def _check_operate_value(self, value):
method __add__ (line 219) | def __add__(self, right):
method __radd__ (line 226) | def __radd__(self, left):
method __sub__ (line 232) | def __sub__(self, right):
method __rsub__ (line 238) | def __rsub__(self, left):
method __mul__ (line 244) | def __mul__(self, right):
method __rmul__ (line 250) | def __rmul__(self, left):
method __div__ (line 256) | def __div__(self, right):
method __truediv__ (line 262) | def __truediv__(self, right):
method __rdiv__ (line 265) | def __rdiv__(self, left):
method __mod__ (line 271) | def __mod__(self, right):
method __rmod__ (line 277) | def __rmod__(self, left):
method __pow__ (line 283) | def __pow__(self, right):
method __float__ (line 289) | def __float__(self):
method __abs__ (line 294) | def __abs__(self):
method abs (line 299) | def abs(self):
method accumulate (line 302) | def accumulate(self, func=None, skipna=True):
method apply (line 311) | def apply(self, func, *args, **kwrds):
method argmax (line 314) | def argmax(self):
method argmin (line 321) | def argmin(self):
method argsort (line 328) | def argsort(self, key=None, reverse=False):
method between (line 348) | def between(self, left, right, boundary='both'):
method cv (line 374) | def cv(self):
method count_values (line 386) | def count_values(self):
method diff (line 390) | def diff(self, lag):
method drop (line 395) | def drop(self, todrop):
method drop_duplicates (line 402) | def drop_duplicates(self, keep=['first', 'last', False]):
method dropna (line 419) | def dropna(self):
method get (line 422) | def get(self, index, default=None):
method has_duplicates (line 428) | def has_duplicates(self):
method normalize (line 431) | def normalize(self):
method isnan (line 436) | def isnan(self):
method map (line 439) | def map(self, func):
method max (line 463) | def max(self, axis=0):
method max_n (line 466) | def max_n(self, n=1):
method min (line 469) | def min(self, axis=0):
method min_n (line 472) | def min_n(self, n=1):
method mean (line 475) | def mean(self, axis=0):
method percenttile (line 478) | def percenttile(self, q):
method pop (line 481) | def pop(self, ind):
method replace (line 495) | def replace(self, old, new):
method sum (line 498) | def sum(self):
method std (line 501) | def std(self):
method tolist (line 511) | def tolist(self):
method toarray (line 514) | def toarray(self):
method unique (line 521) | def unique(self):
FILE: DaPy/core/base/Sheet.py
class SeriesSet (line 38) | class SeriesSet(BaseSheet):
method __init__ (line 43) | def __init__(self, series=None, columns=None, nan=float('nan')):
method info (line 48) | def info(self):
method missing (line 53) | def missing(self):
method T (line 58) | def T(self):
method __eq__ (line 62) | def __eq__(self, other):
method __gt__ (line 78) | def __gt__(self, other):
method __ge__ (line 81) | def __ge__(self, other):
method __lt__ (line 84) | def __lt__(self, other):
method __le__ (line 87) | def __le__(self, other):
method accumulate (line 91) | def accumulate(self, func=None, cols=None, skipna=True, inplace=False):
method append_col (line 120) | def append_col(self, series, variable_name=None):
method append_row (line 165) | def append_row(self, row):
method apply (line 217) | def apply(self, func, cols=None, axis=0, *args, **kwrds):
method map (line 264) | def map(self, func, cols=None, inplace=False):
method set_index (line 294) | def set_index(self, columns):
method corr (line 335) | def corr(self, method='pearson', col=None):
method copy (line 384) | def copy(self):
method count (line 388) | def count(self, value, col=None, row=None):
method count_nan (line 463) | def count_nan(self, axis=0):
method count_values (line 472) | def count_values(self, col=None):
method query (line 519) | def query(self, expression, col=None, limit=1000):
method describe (line 577) | def describe(self, level=0):
method drop (line 649) | def drop(self, index=-1, axis=0, inplace=False):
method drop_col (line 687) | def drop_col(self, index=-1, inplace=False):
method diff (line 715) | def diff(self, lag=1, cols=None, inplace=False):
method drop_row (line 721) | def drop_row(self, index=-1, inplace=True):
method dropna (line 729) | def dropna(self, axis=0, how='any', inplace=False):
method drop_duplicates (line 825) | def drop_duplicates(self, col=None, keep='first', inplace=False):
method extend (line 840) | def extend(self, item, inplace=False):
method fillna (line 887) | def fillna(self, fill_with=None, col=None, method=None, limit=None):
method flatten (line 924) | def flatten(self, axis=0):
method from_file (line 929) | def from_file(cls, addr, **kwrd):
method get (line 1045) | def get(self, key, default=None):
method get_best_features (line 1052) | def get_best_features(self, method='variance', X=None, Y=None, top_k=1):
method get_categories (line 1059) | def get_categories(self, cols, cut_points, group_name,
method get_date_label (line 1067) | def get_date_label(self, cols, daytime=True,
method get_dummies (line 1089) | def get_dummies(self, cols=None, value=1, inplace=False):
method get_interactions (line 1129) | def get_interactions(self, n_power=2, cols=None, inplace=False):
method get_ranks (line 1182) | def get_ranks(self, cols=None, duplicate='mean', inplace=False):
method get_nan_instrument (line 1217) | def get_nan_instrument(self, cols=None, inplace=False):
method get_numeric_label (line 1224) | def get_numeric_label(self, cols=None, inplace=False):
method groupby (line 1229) | def groupby(self, keys, func=None, apply_col=None):
method sort (line 1315) | def sort(self, *orderby):
method show (line 1360) | def show(self, max_lines=None, max_display=75, max_col_size=25, multi_...
method iter_groupby (line 1476) | def iter_groupby(self, keys, func=None, apply_col=None):
method items (line 1507) | def items(self):
method iter_items (line 1511) | def iter_items(self):
method iter_rows (line 1516) | def iter_rows(self):
method iter_values (line 1521) | def iter_values(self):
method iloc (line 1526) | def iloc(self, indexs):
method insert_row (line 1532) | def insert_row(self, index, new_row):
method insert_col (line 1575) | def insert_col(self, index, new_series, new_name=None):
method join (line 1620) | def join(self, other, inplace=False):
method keys (line 1668) | def keys(self):
method merge (line 1672) | def merge(self, other, how='inner', self_on=0, right_on=0):
method normalized (line 1750) | def normalized(self, process='NORMAL', cols=None, inplace=False):
method pop (line 1829) | def pop(self, index=-1, axis=0):
method pop_row (line 1862) | def pop_row(self, index=-1):
method pop_col (line 1904) | def pop_col(self, col=-1):
method reverse (line 1944) | def reverse(self, axis=0, inplace=True):
method reshape (line 1950) | def reshape(self, nshape=None, axis=0):
method replace (line 2020) | def replace(self, old, new, col=None, regex=False):
method update (line 2076) | def update(self, where, **set_values):
method shuffle (line 2081) | def shuffle(self, inplace=False):
method select (line 2087) | def select(self, where, col=None, limit=1000):
method sum (line 2160) | def sum(self, axis=0, col=None):
method values (line 2173) | def values(self):
class Frame (line 2178) | class Frame(BaseSheet):
method __init__ (line 2183) | def __init__(self, series=None, columns=None, nan=float('nan')):
FILE: DaPy/core/base/absents/Frame.py
class Frame (line 1) | class Frame(BaseSheet):
method __init__ (line 5) | def __init__(self, frame=None, columns=None, nan=None):
method info (line 10) | def info(self):
method T (line 27) | def T(self):
method _init_col (line 30) | def _init_col(self, obj, columns):
method _init_frame (line 38) | def _init_frame(self, frame, columns):
method _init_dict (line 46) | def _init_dict(self, frame, columns):
method _init_like_table (line 59) | def _init_like_table(self, frame, columns):
method _init_like_seq (line 73) | def _init_like_seq(self, frame, columns):
method __repr__ (line 79) | def __repr__(self):
method _getslice_col (line 82) | def _getslice_col(self, i, j):
method _getslice_ln (line 86) | def _getslice_ln(self, i, j, k):
method __getitem__ (line 89) | def __getitem__(self, interval):
method __iter__ (line 107) | def __iter__(self):
method append_row (line 111) | def append_row(self, item):
method append_col (line 117) | def append_col(self, series, variable_name=None):
method count (line 134) | def count(self, X, point1=None, point2=None):
method extend (line 149) | def extend(self, other, inplace=False):
method join (line 183) | def join(self, other, inplace=False):
method insert_row (line 210) | def insert_row(self, index, item):
method insert_col (line 216) | def insert_col(self, index, series, variable_name=None):
method items (line 234) | def items(self):
method keys (line 238) | def keys(self):
method pop_row (line 241) | def pop_row(self, pos=-1):
method from_file (line 258) | def from_file(self, addr, **kwrd):
method reverse (line 263) | def reverse(self):
method shuffle (line 266) | def shuffle(self):
method _values (line 269) | def _values(self):
method values (line 273) | def values(self):
method pop_col (line 278) | def pop_col(self, pos=-1):
method dropna (line 302) | def dropna(self, axis='LINE'):
FILE: DaPy/core/base/row.py
class Row (line 8) | class Row(Sequence):
method __init__ (line 46) | def __init__(self, sheet, line):
method sheet (line 51) | def sheet(self):
method columns (line 55) | def columns(self):
method data (line 59) | def data(self):
method __iter__ (line 62) | def __iter__(self):
method __getattr__ (line 66) | def __getattr__(self, index):
method __eq__ (line 71) | def __eq__(self, y):
method __contains__ (line 79) | def __contains__(self, y):
method __delitem__ (line 82) | def __delitem__(self, y):
method __len__ (line 88) | def __len__(self):
method __str__ (line 91) | def __str__(self):
method __repr__ (line 94) | def __repr__(self):
method __getitem__ (line 97) | def __getitem__(self, index):
method __setitem__ (line 128) | def __setitem__(self, index, value):
method _get_new_column (line 149) | def _get_new_column(self, value):
method append (line 154) | def append(self, value):
method count (line 158) | def count(self, value):
method extend (line 161) | def extend(self, iterable):
method get (line 166) | def get(self, index, default=None):
method index (line 175) | def index(self, value):
method insert (line 178) | def insert(self, index, value):
method pop (line 182) | def pop(self, index):
method remove (line 185) | def remove(self, value):
method tolist (line 189) | def tolist(self):
FILE: DaPy/core/base/utils/__init__.py
function isnan (line 29) | def isnan(value):
function auto_str2value (line 42) | def auto_str2value(value, dtype=None):
function argsort (line 104) | def argsort(seq, key=None, reverse=False):
function hash_sort (line 123) | def hash_sort(records, *orders):
function auto_plus_one (line 164) | def auto_plus_one(exists, item, start=1):
function count_nan (line 170) | def count_nan(nan_func, series):
function count_not_char (line 173) | def count_not_char(string):
function count_str_printed_length (line 176) | def count_str_printed_length(string):
function string_align (line 179) | def string_align(string, length):
FILE: DaPy/core/base/utils/py_string_transfer.py
function str2bool (line 7) | def str2bool(val):
function str2datetime (line 15) | def str2datetime(val):
FILE: DaPy/core/base/utils/utils_2to3.py
function range (line 11) | def range(x, y=None, z=1):
FILE: DaPy/core/base/utils/utils_grammar_parser.py
function strtodate (line 8) | def strtodate(value, day='1900-1-1', time='0:0:0'):
function _str2date (line 18) | def _str2date(value):
function _str2bool (line 24) | def _str2bool(value):
function _str2percent (line 32) | def _str2percent(value):
FILE: DaPy/core/base/utils/utils_isfunc.py
function is_dict (line 12) | def is_dict(val):
function is_value (line 15) | def is_value(n):
function is_math (line 28) | def is_math(n):
function is_str (line 41) | def is_str(value):
function is_iter (line 47) | def is_iter(obj):
function is_seq (line 58) | def is_seq(obj):
function is_empty (line 65) | def is_empty(obj):
FILE: DaPy/core/base/utils/utils_join_table.py
function inner_join (line 8) | def inner_join(left, other, left_on, right_on, joined):
function outer_join (line 26) | def outer_join(left, other, left_on, right_on, joined):
function left_join (line 54) | def left_join(left, right, left_on, right_on, joined):
function create_join_by_index (line 67) | def create_join_by_index(left, other, left_index, right_index, joined, a...
FILE: DaPy/core/base/utils/utils_regression.py
function simple_linear_reg (line 1) | def simple_linear_reg(x, y):
FILE: DaPy/core/base/utils/utils_str_transfer.py
function strtodate (line 8) | def strtodate(value, day='1900-1-1', time='0:0:0'):
function _str2date (line 18) | def _str2date(value):
function _str2bool (line 24) | def _str2bool(value):
function _str2percent (line 32) | def _str2percent(value):
FILE: DaPy/core/base/utils/utils_toolkits.py
class Timer (line 5) | class Timer(object):
method __init__ (line 6) | def __init__(self):
FILE: DaPy/core/io.py
function create_sheet (line 11) | def create_sheet(dtype, data, titles, nan):
function parse_addr (line 24) | def parse_addr(addr):
function parse_mysql_server (line 55) | def parse_mysql_server(cur, fname):
function parse_db (line 67) | def parse_db(cur, dtype, nan):
function parse_sav (line 81) | def parse_sav(doc, dtype, nan):
function parse_excel (line 86) | def parse_excel(dtype, addr, fline, tline, nan):
function parse_html (line 105) | def parse_html(text, dtype, miss_symbol, nan, sheetname):
function parse_sql (line 143) | def parse_sql(doc, nan):
function write_sql (line 164) | def write_sql(doc, sheet, sheet_name):
function write_txt (line 187) | def write_txt(f, data, newline, delimiter):
function write_xls (line 222) | def write_xls(worksheet, data):
function write_html (line 265) | def write_html(f, data):
function write_db (line 305) | def write_db(cur, sheet, data, if_exists, mode):
FILE: DaPy/core/sqlparser.py
function parse_create_statement (line 13) | def parse_create_statement(string):
function parse_insert_statement (line 29) | def parse_insert_statement(string, dtypes=None, nan=None):
FILE: DaPy/datasets/__init__.py
function wine (line 7) | def wine():
function iris (line 14) | def iris():
function example (line 21) | def example():
function adult (line 26) | def adult():
FILE: DaPy/io.py
function read (line 6) | def read(addr, dtype='col', **kward):
function save (line 18) | def save(addr, data, **kward):
function encode (line 27) | def encode(code='cp936'):
FILE: DaPy/matlib.py
function P (line 18) | def P(n, k):
function C (line 36) | def C(n, k):
function add (line 54) | def add(m1, m2):
function _abs (line 63) | def _abs(data):
function sign (line 83) | def sign(x):
function multiply (line 89) | def multiply(m1, m2):
function dot (line 96) | def dot(matrix_1, matrix_2):
function exp (line 125) | def exp(other):
function create_mat (line 143) | def create_mat(shape, num):
function cumsum (line 146) | def cumsum(series):
function count (line 154) | def count(df, value, axis=None):
function zeros (line 163) | def zeros(shape):
function ones (line 166) | def ones(shape):
function diag (line 169) | def diag(values):
function diff (line 172) | def diff(seq, lag=1):
function log (line 175) | def log(data, base=2.71828183):
function boxcox (line 182) | def boxcox(value, lambda_=1, a=0, k=1):
function _sum (line 187) | def _sum(data, axis=None):
function _max (line 240) | def _max(data, axis=None):
function median (line 249) | def median(data):
function mean (line 258) | def mean(data, axis=None):
function std (line 312) | def std(series):
function cov (line 315) | def cov(x, y=None, **kwrds):
function corr (line 356) | def corr(x, y, method='pearson'):
function _corr_kendall (line 435) | def _corr_kendall(x, y):
function _corr_spearman (line 478) | def _corr_spearman(x, y):
function _corr_pearson (line 502) | def _corr_pearson(x, y):
function frequency (line 513) | def frequency(data, cut=0.5):
function quantiles (line 526) | def quantiles(data, points=[0.05,0.1,0.25,0.5,0.75,0.9,0.95]):
function distribution (line 531) | def distribution(data, breaks=10, x_label=False):
function describe (line 550) | def describe(data, detail=0):
FILE: DaPy/methods/classifiers/classifier.py
function proba2label (line 6) | def proba2label(seq, labels):
function clf_multilabel (line 13) | def clf_multilabel(seq, groupby=None):
function clf_binlabel (line 22) | def clf_binlabel(seq, labels, cutpoint=0.5):
class BaseClassifier (line 26) | class BaseClassifier(object):
method __init__ (line 27) | def __init__(self):
method labels (line 31) | def labels(self):
method _calculate_accuracy (line 34) | def _calculate_accuracy(self, predict, target):
method predict_proba (line 39) | def predict_proba(self, X):
method predict (line 55) | def predict(self, X):
FILE: DaPy/methods/classifiers/linear_models.py
class LogistClassifier (line 5) | class LogistClassifier(BaseLinearModel, BaseClassifier):
method __init__ (line 6) | def __init__(self, engine='numpy', learn_rate=0.005, l1_penalty=0, l2_...
method _check_target_labels (line 11) | def _check_target_labels(self, target):
method _forecast (line 16) | def _forecast(self, X):
method fit (line 19) | def fit(self, X, Y, epoch=500, early_stop=True, verbose=False):
FILE: DaPy/methods/classifiers/mlp.py
class MLPClassifier (line 10) | class MLPClassifier(BaseMLP, BaseClassifier):
method __init__ (line 12) | def __init__(self, engine='numpy', learn_rate=0.05, l1_penalty=0, l2_p...
method _check_target_labels (line 17) | def _check_target_labels(self, target):
method fit (line 24) | def fit(self, X, Y, n_epoch=500, n_layers=None,
FILE: DaPy/methods/classifiers/tree.py
class DecisionTreeClassifier (line 7) | class DecisionTreeClassifier(object):
method __init__ (line 9) | def __init__(self, max_depth=None):
method __getitem__ (line 15) | def __getitem__(self, key):
method __repr__ (line 18) | def __repr__(self):
method n_features (line 22) | def n_features(self):
method n_outputs (line 26) | def n_outputs(self):
method root (line 30) | def root(self):
method items (line 33) | def items(self):
method keys (line 37) | def keys(self):
method _cal_shannon (line 41) | def _cal_shannon(self, data):
method _get_best_feature (line 50) | def _get_best_feature(self, X, Y, tol_gain_ratio=0.0001):
method _create_tree (line 71) | def _create_tree(self, X, Y, feature_name):
method fit (line 98) | def fit(self, X, Y):
method predict_once (line 109) | def predict_once(self, row):
method predict (line 124) | def predict(self, X):
method export_graphviz (line 128) | def export_graphviz(self, outfile=None):
method most_important_feature (line 167) | def most_important_feature(self, top='all'):
FILE: DaPy/methods/core/base/activators.py
function check_activations (line 8) | def check_activations(func):
class Activators (line 15) | class Activators(BaseEngineModel):
method __init__ (line 16) | def __init__(self, engine):
method __call__ (line 19) | def __call__(self, func_name):
method get_actfunc_by_str (line 22) | def get_actfunc_by_str(self, func_name):
method sigmoid (line 38) | def sigmoid(self, x, diff=False):
method tanh (line 43) | def tanh(self, x, diff=False):
method linear (line 49) | def linear(self, x, diff=False):
method radb (line 54) | def radb(self, x, diff=False):
method relu (line 60) | def relu(self, x, diff=False):
method softmax (line 65) | def softmax(self, x, diff=False):
FILE: DaPy/methods/core/base/layers.py
class Layer (line 9) | class Layer(BaseEngineModel):
method __init__ (line 10) | def __init__(self, engine, function, str_activation):
method __repr__ (line 15) | def __repr__(self):
method activation (line 19) | def activation(self):
method activation (line 23) | def activation(self, other):
method __getstate__ (line 27) | def __getstate__(self):
method __setstate__ (line 33) | def __setstate__(self, pkl):
method propagation (line 39) | def propagation(self, *args, **kwrds):
method backward (line 42) | def backward(self, *args, **kwrds):
class Input (line 46) | class Input(Layer):
method __init__ (line 51) | def __init__(self, engine, in_cells, *args, **kwrds):
method shape (line 57) | def shape(self):
method propagation (line 60) | def propagation(self, x):
class Dense (line 66) | class Dense(Layer):
method __init__ (line 75) | def __init__(self, engine, n_in, n_out, activation, str_act, init_weig...
method shape (line 80) | def shape(self):
method _init_parameters (line 83) | def _init_parameters(self, in_cells, out_cells, mode='MSRA'):
method propagation (line 113) | def propagation(self, input_):
method backward (line 118) | def backward(self, gradient, alpha):
class Output (line 124) | class Output(Dense):
method __init__ (line 129) | def __init__(self, engine, n_in, n_out, activation, init_weight='Xavie...
FILE: DaPy/methods/core/base/models.py
class BaseEngineModel (line 6) | class BaseEngineModel(object):
method __init__ (line 8) | def __init__(self, engine='numpy'):
method engine (line 12) | def engine(self):
method engine (line 17) | def engine(self, new_engine):
method __call__ (line 29) | def __call__(self, x):
method __getstate__ (line 32) | def __getstate__(self):
method __setstate__ (line 37) | def __setstate__(self, pkl):
method _abs (line 40) | def _abs(self, x):
method _dot (line 43) | def _dot(self, left, right):
method _exp (line 46) | def _exp(self, x):
method _mat (line 49) | def _mat(self, x):
method _mul (line 52) | def _mul(self, a, b):
method _mean (line 55) | def _mean(self, x, axis=None):
method _pow (line 58) | def _pow(self, x, power=2):
method _log (line 67) | def _log(self, x, grad=2):
method _sum (line 70) | def _sum(self, x, axis=None):
method _check_addr (line 73) | def _check_addr(self, addr, mode):
method _zeros (line 78) | def _zeros(self, shape):
method _ones (line 81) | def _ones(self, shape):
method _check_input_X_matrix (line 84) | def _check_input_X_matrix(self, mat):
FILE: DaPy/methods/core/base/utils.py
function eng2str (line 3) | def eng2str(obj):
function str2eng (line 6) | def str2eng(obj):
FILE: DaPy/methods/core/bp_model.py
class BaseBPModel (line 6) | class BaseBPModel(BaseEngineModel):
method __init__ (line 7) | def __init__(self, engine, learn_rate, l1_penalty, l2_penalty):
method accuracy (line 17) | def accuracy(self):
method cost_history (line 21) | def cost_history(self):
method learn_rate (line 25) | def learn_rate(self):
method learn_rate (line 29) | def learn_rate(self, new_rate):
method l1_penalty (line 35) | def l1_penalty(self):
method l1_penalty (line 39) | def l1_penalty(self, new_l1):
method l2_penalty (line 45) | def l2_penalty(self):
method l2_penalty (line 49) | def l2_penalty(self, new_l2):
method __getstate__ (line 54) | def __getstate__(self):
method __setstate__ (line 59) | def __setstate__(self, pkl):
method _train (line 68) | def _train(self, X, Y, epoch=500, verbose=True, early_stop=False):
method plot_error (line 109) | def plot_error(self):
FILE: DaPy/methods/core/linear_model.py
class BaseLinearModel (line 15) | class BaseLinearModel(BaseBPModel):
method __init__ (line 16) | def __init__(self, engine, learn_rate, l1_penalty, l2_penalty, fit_int...
method intercept (line 22) | def intercept(self):
method intercept (line 26) | def intercept(self, set_intercept):
method _backward (line 30) | def _backward(self, X, gradient):
method _calculate_accuracy (line 37) | def _calculate_accuracy(self, predict, target):
method _calculate_backward_error (line 40) | def _calculate_backward_error(self, predict, target):
method _create (line 43) | def _create(self, X, Y):
method _fit (line 47) | def _fit(self, X, Y, epoch=500, early_stop=True, verbose=False):
FILE: DaPy/methods/core/multilayer_perceptron.py
class BaseMLP (line 23) | class BaseMLP(BaseBPModel):
method __init__ (line 68) | def __init__(self, engine, learn_rate, l1_penalty, l2_penalty, upfacto...
method weight (line 102) | def weight(self):
method layers (line 107) | def layers(self):
method loss_func (line 111) | def loss_func(self):
method loss_func (line 115) | def loss_func(self, new):
method __repr__ (line 119) | def __repr__(self):
method __setstate__ (line 145) | def __setstate__(self, pkl):
method add_layer (line 154) | def add_layer(self, layer):
method _create (line 158) | def _create(self, n_in, n_out, layers=None, activators=None):
method _check_cells (line 201) | def _check_cells(self, input_, hidden, output):
method _check_funcs (line 210) | def _check_funcs(self, funcs, lenth_layer):
method _calculate_backward_error (line 215) | def _calculate_backward_error(self, predict, target):
method _forecast (line 218) | def _forecast(self, output):
method _fit (line 223) | def _fit(self, X, Y, epoch=500, layers=None, activators=None, threasho...
method _backward (line 235) | def _backward(self, x, gradient):
method _auto_adjust_learn_rate (line 240) | def _auto_adjust_learn_rate(self):
method save (line 243) | def save(self, addr):
method load (line 253) | def load(self, fp):
FILE: DaPy/methods/core/pagerank.py
class PageRank (line 7) | class PageRank(BaseEngineModel):
method __init__ (line 8) | def __init__(self, engine='numpy', random_walk_rate=0.85):
method random_walk_rate (line 13) | def random_walk_rate(self):
method random_walk_rate (line 17) | def random_walk_rate(self, rate):
method __setstate__ (line 22) | def __setstate__(self, args):
method __call__ (line 26) | def __call__(self, X_mat, stochastic_matrix=None, min_error=0.0001, ma...
method transform (line 29) | def transform(self, stochastic_matrix, init_weight=None, min_error=0.0...
FILE: DaPy/methods/core/tfidf.py
function count_iter (line 14) | def count_iter(iterable):
class TfidfCounter (line 23) | class TfidfCounter(BaseEngineModel):
method __init__ (line 24) | def __init__(self, ngram=1, engine='numpy'):
method ngram (line 30) | def ngram(self):
method ngram (line 34) | def ngram(self, num_words):
method tfidf (line 42) | def tfidf(self):
method tfidf (line 46) | def tfidf(self, values):
method __setstate__ (line 50) | def __setstate__(self, args):
method _pad (line 54) | def _pad(self, string):
method _get_ngram (line 57) | def _get_ngram(self, string):
method _nlargest (line 66) | def _nlargest(self, n):
method nlargest (line 69) | def nlargest(self, n):
method fit (line 72) | def fit(self, documents, labels, min_freq=1.0, threashold=0.01):
method transform (line 96) | def transform(self, documents, max_num_tokens=500):
method fit_transform (line 110) | def fit_transform(self, documents, labels, min_freq=1.0, threashold=0....
FILE: DaPy/methods/evaluator.py
function ConfuMat (line 7) | def ConfuMat(Y, y_, labels):
function Accuracy (line 22) | def Accuracy(confumat):
function Kappa (line 26) | def Kappa(confumat):
function Auc (line 34) | def Auc(target, predict, n_bins=100):
function Performance (line 54) | def Performance(predictor, data, target, mode='reg'):
class Score (line 95) | class Score(object):
method error (line 100) | def error(target, predict):
method MAE (line 107) | def MAE(target, predict):
method MSE (line 111) | def MSE(target, predict):
method R2_score (line 115) | def R2_score(target, predict):
method MAPE (line 121) | def MAPE(target, predict):
FILE: DaPy/methods/regressors/lr.py
class LinearRegressor (line 3) | class LinearRegressor(BaseLinearModel):
method __init__ (line 4) | def __init__(self, engine='numpy', learn_rate=0.05, l1_penalty=0, l2_p...
method _forecast (line 7) | def _forecast(self, X):
method fit (line 10) | def fit(self, X, Y, epoch=500, early_stop=True, verbose=False):
method predict (line 14) | def predict(self, X):
FILE: DaPy/methods/statistic/compare_position.py
function IndependentTTest (line 16) | def IndependentTTest(x, center=0, alpha=.05):
function SignTest (line 23) | def SignTest(series, center, side='both', alpha=0.05):
function CoxStautTest (line 67) | def CoxStautTest(series, H0='increase'):
function WicoxonTest (line 82) | def WicoxonTest(series, center, side='both', alpha=0.05):
function RunTest (line 109) | def RunTest(series, side='both', alpha=0.05):
function BrownMoodTest (line 126) | def BrownMoodTest(X, Y, side='equal', alpha=0.05):
function WilcoxonMannWhitneyTest (line 192) | def WilcoxonMannWhitneyTest(X, Y, side='equal', alpha=0.05):
FILE: DaPy/methods/statistic/compare_scaler.py
function ANOVA (line 13) | def ANOVA(data, cluster):
function MoodTest (line 39) | def MoodTest(X, Y, side='equal', alpha=0.05):
FILE: DaPy/methods/statistic/discriminant_analysis.py
class DiscriminantAnalysis (line 9) | class DiscriminantAnalysis(BaseEngineModel):
method __init__ (line 10) | def __init__(self, engine='numpy', solve='FISHER'):
method I (line 19) | def I(self):
method C (line 23) | def C(self):
method report (line 27) | def report(self):
method confumat (line 31) | def confumat(self):
method _create_report (line 34) | def _create_report(self, **kwrds):
method _Summary (line 41) | def _Summary(self):
method _Info (line 49) | def _Info(self, shape):
method _Perf (line 56) | def _Perf(self, X):
method _calculate_confumat (line 63) | def _calculate_confumat(self, X):
method _calculate_xbar (line 72) | def _calculate_xbar(self, X):
method _calculate_Sp (line 75) | def _calculate_Sp(self, X):
method _fit_linear (line 81) | def _fit_linear(self, X):
method _fit_fisher (line 88) | def _fit_fisher(self, X, acr=1.):
method _predict_linear (line 117) | def _predict_linear(self, X):
method _predict_fisher (line 121) | def _predict_fisher(self, X):
method fit (line 129) | def fit(self, *X, **kwrds):
method predict_proba (line 151) | def predict_proba(self, X):
method predict (line 159) | def predict(self, X):
FILE: DaPy/methods/statistic/distribution.py
function unsupportedTest (line 3) | def unsupportedTest(*args, **kwrds):
FILE: DaPy/methods/statistic/kMeans.py
class kMeans (line 27) | class kMeans(object):
method __init__ (line 28) | def __init__(self, engine):
method distEclud (line 31) | def distEclud(self, vecA, vecB):
method fit (line 34) | def fit(self, k, data):
FILE: DaPy/methods/utils.py
function plot_reg (line 11) | def plot_reg(y_hat, y, res):
FILE: DaPy/operation.py
function merge (line 10) | def merge(sheets=(), keys=(), how='inner'):
function delete (line 77) | def delete(data, index, axis=0):
function concatenate (line 109) | def concatenate(tup, axis=0):
function column_stack (line 119) | def column_stack(tup):
function _repeat (line 169) | def _repeat(val, times):
function row_stack (line 173) | def row_stack(tup):
function get_ranks (line 210) | def get_ranks(series, duplicate='mean'):
function get_dummies (line 255) | def get_dummies(data, value=1, dtype='mat'):
function get_categories (line 320) | def get_categories(array, cut_points, group_name, boundary=(False, True)):
FILE: DaPy/tests/scripts/performance.py
function test_Pandas (line 17) | def test_Pandas(files):
function test_Numpy (line 31) | def test_Numpy(files):
function test_DaPy (line 48) | def test_DaPy(files):
function main (line 65) | def main(files):
FILE: DaPy/tests/scripts/test_matrix.py
function numpy_multi (line 13) | def numpy_multi():
function dapy_multi (line 17) | def dapy_multi():
function numpy_dot (line 21) | def numpy_dot():
function dapy_dot (line 24) | def dapy_dot():
function numpy_attribute (line 27) | def numpy_attribute():
function dapy_attribute (line 32) | def dapy_attribute():
FILE: DaPy/tests/test_CoreBaseIndexArray.py
class Test_Tools (line 9) | class Test_Tools(TestCase):
method setUp (line 10) | def setUp(self):
method test_init (line 14) | def test_init(self):
method test_getitem (line 21) | def test_getitem(self):
method test_between (line 25) | def test_between(self):
method test_index (line 35) | def test_index(self):
method test_equal (line 41) | def test_equal(self):
method test_unequal (line 46) | def test_unequal(self):
method test_lower (line 49) | def test_lower(self):
FILE: DaPy/tests/test_CoreBaseSeries.py
class Test_Tools (line 9) | class Test_Tools(TestCase):
method setUp (line 10) | def setUp(self):
method test_init (line 14) | def test_init(self):
method test_getitem (line 21) | def test_getitem(self):
method test_between (line 25) | def test_between(self):
method test_index (line 35) | def test_index(self):
method test_equal (line 41) | def test_equal(self):
method test_unequal (line 46) | def test_unequal(self):
method test_lower (line 49) | def test_lower(self):
FILE: DaPy/tests/test_CoreBaseSheet.py
class Test0_InitData (line 18) | class Test0_InitData(TestCase):
method isinit_sheet_success (line 22) | def isinit_sheet_success(self, table, data, shape, col, nan, miss):
method test_init_table (line 30) | def test_init_table(self):
method test_init_dict (line 34) | def test_init_dict(self):
method test_init_seq (line 38) | def test_init_seq(self):
method test_init_col (line 48) | def test_init_col(self):
method test_init_empty (line 55) | def test_init_empty(self):
class Test2_Transfer (line 65) | class Test2_Transfer(TestCase):
method setUp (line 66) | def setUp(self):
method test_numpy_dapy (line 72) | def test_numpy_dapy(self):
method test_pandas_dapy (line 85) | def test_pandas_dapy(self):
class Test1_CoreOperations (line 98) | class Test1_CoreOperations(TestCase):
method setUp (line 99) | def setUp(self):
method test_getitem (line 102) | def test_getitem(self):
method test_append (line 156) | def test_append(self):
method test_insert (line 177) | def test_insert(self):
method test_extend (line 200) | def test_extend(self):
method test_join (line 210) | def test_join(self):
method test_merge (line 219) | def test_merge(self):
method test_drop (line 262) | def test_drop(self):
method test_reshape (line 272) | def test_reshape(self):
method test_get (line 281) | def test_get(self):
method test_count (line 285) | def test_count(self):
method test_count_values (line 292) | def test_count_values(self):
method test_pop (line 304) | def test_pop(self):
FILE: DaPy/tests/test_CoreBaseTools.py
class Test_Tools (line 16) | class Test_Tools(TestCase):
method test_str2value (line 17) | def test_str2value(self):
method test_GetSortedIndex (line 26) | def test_GetSortedIndex(self):
method test_hash_sort (line 30) | def test_hash_sort(self):
method test_autoone (line 38) | def test_autoone(self):
method test_isvalue (line 46) | def test_isvalue(self):
method test_ismath (line 51) | def test_ismath(self):
method test_group (line 55) | def test_group(self):
FILE: DaPy/tests/test_methods.py
class Test_Tools (line 8) | class Test_Tools(TestCase):
method setUp (line 9) | def setUp(self):
method test_mlpclf (line 16) | def test_mlpclf(self):
FILE: clib/io.c
type PyObject (line 336) | typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *co...
type PyObject (line 337) | typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, ...
type Py_tss_t (line 378) | typedef int Py_tss_t;
function CYTHON_INLINE (line 379) | static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
function CYTHON_INLINE (line 383) | static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
function CYTHON_INLINE (line 388) | static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
function CYTHON_INLINE (line 391) | static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
function CYTHON_INLINE (line 394) | static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
function CYTHON_INLINE (line 398) | static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
function CYTHON_INLINE (line 401) | static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
type Py_hash_t (line 525) | typedef long Py_hash_t;
type __Pyx_PyAsyncMethodsStruct (line 548) | typedef struct {
function CYTHON_INLINE (line 562) | static CYTHON_INLINE float __PYX_NAN() {
type __Pyx_StringTabEntry (line 602) | typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const c...
function CYTHON_INLINE (line 623) | static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t l...
function CYTHON_INLINE (line 672) | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
function __Pyx_init_sys_getdefaultencoding_params (line 704) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function __Pyx_init_sys_getdefaultencoding_params (line 754) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function CYTHON_INLINE (line 786) | static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__char________nogil_to_py (line 807) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__ch...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char________nogil_to_py (line 808) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char__...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py (line 809) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py
type __pyx_opt_args_2io_read_csv (line 810) | struct __pyx_opt_args_2io_read_csv
type __pyx_opt_args_2io_read_csv (line 819) | struct __pyx_opt_args_2io_read_csv {
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__char________nogil_to_py (line 833) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__ch...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char________nogil_to_py (line 838) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char__...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py (line 843) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to...
type __Pyx_RefNannyAPIStruct (line 855) | typedef struct {
function CYTHON_INLINE (line 1095) | static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
type __pyx_CyFunctionObject (line 1147) | typedef struct {
type __Pyx_CodeObjectCacheEntry (line 1212) | typedef struct {
type __Pyx_CodeObjectCache (line 1216) | struct __Pyx_CodeObjectCache {
type __Pyx_CodeObjectCache (line 1221) | struct __Pyx_CodeObjectCache
type __pyx_opt_args_2io_read_csv (line 1287) | struct __pyx_opt_args_2io_read_csv
function PY_LONG_LONG (line 1431) | static PY_LONG_LONG __pyx_f_2io_str2int(char *__pyx_v_string, CYTHON_UNU...
function PyObject (line 1462) | static PyObject *__pyx_pw_2io_1str2int(PyObject *__pyx_self, PyObject *_...
function PyObject (line 1483) | static PyObject *__pyx_pf_2io_str2int(CYTHON_UNUSED PyObject *__pyx_self...
function __pyx_f_2io_str2float (line 1515) | static double __pyx_f_2io_str2float(char *__pyx_v_string, CYTHON_UNUSED ...
function PyObject (line 1546) | static PyObject *__pyx_pw_2io_3str2float(PyObject *__pyx_self, PyObject ...
function PyObject (line 1567) | static PyObject *__pyx_pf_2io_2str2float(CYTHON_UNUSED PyObject *__pyx_s...
function __pyx_f_2io_str2pct (line 1599) | static double __pyx_f_2io_str2pct(char *__pyx_v_string, CYTHON_UNUSED in...
function PyObject (line 1640) | static PyObject *__pyx_pw_2io_5str2pct(PyObject *__pyx_self, PyObject *_...
function PyObject (line 1661) | static PyObject *__pyx_pf_2io_4str2pct(CYTHON_UNUSED PyObject *__pyx_sel...
function __pyx_f_2io_str2bool (line 1693) | static int __pyx_f_2io_str2bool(char *__pyx_v_string, CYTHON_UNUSED int ...
function PyObject (line 1743) | static PyObject *__pyx_pw_2io_7str2bool(PyObject *__pyx_self, PyObject *...
function PyObject (line 1764) | static PyObject *__pyx_pf_2io_6str2bool(CYTHON_UNUSED PyObject *__pyx_se...
function PyObject (line 1795) | static PyObject *__pyx_f_2io_str2date(char *__pyx_v_string) {
function PyObject (line 1946) | static PyObject *__pyx_f_2io_str2datetime(char *__pyx_v_string, CYTHON_U...
function PyObject (line 2175) | static PyObject *__pyx_pw_2io_9str2datetime(PyObject *__pyx_self, PyObje...
function PyObject (line 2196) | static PyObject *__pyx_pf_2io_8str2datetime(CYTHON_UNUSED PyObject *__py...
function PyObject (line 2227) | static PyObject *__pyx_f_2io_analyze_str_type(char *__pyx_v_string) {
function PyObject (line 2587) | static PyObject *__pyx_f_2io_read_csv(PyObject *__pyx_v_addr, CYTHON_UNU...
function PyObject (line 2989) | static PyObject *__pyx_pw_2io_11read_csv(PyObject *__pyx_self, PyObject ...
function PyObject (line 3087) | static PyObject *__pyx_pf_2io_10read_csv(CYTHON_UNUSED PyObject *__pyx_s...
function PyObject (line 3127) | static PyObject *__pyx_pw_11cfunc_dot_to_py_56__Pyx_CFunc_long__long____...
function PyObject (line 3148) | static PyObject *__pyx_pf_11cfunc_dot_to_py_56__Pyx_CFunc_long__long____...
function PyObject (line 3201) | static PyObject *__Pyx_CFunc_long__long____const__char________nogil_to_p...
function PyObject (line 3275) | static PyObject *__pyx_pw_11cfunc_dot_to_py_52__Pyx_CFunc_double____cons...
function PyObject (line 3296) | static PyObject *__pyx_pf_11cfunc_dot_to_py_52__Pyx_CFunc_double____cons...
function PyObject (line 3349) | static PyObject *__Pyx_CFunc_double____const__char________nogil_to_py(do...
function PyObject (line 3423) | static PyObject *__pyx_pw_11cfunc_dot_to_py_38__Pyx_CFunc_object____char...
function PyObject (line 3444) | static PyObject *__pyx_pf_11cfunc_dot_to_py_38__Pyx_CFunc_object____char...
function PyObject (line 3495) | static PyObject *__Pyx_CFunc_object____char_______to_py(PyObject *(*__py...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__char________nogil_to_py (line 3557) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__ch...
function PyObject (line 3560) | static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_long__long...
function __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_long__long____const__char________nogil_to_py (line 3573) | static void __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_long__long_...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__char________nogil_to_py (line 3584) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_long__long____const__ch...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char________nogil_to_py (line 3639) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char__...
function PyObject (line 3642) | static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_double____...
function __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_double____const__char________nogil_to_py (line 3655) | static void __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_double____c...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char________nogil_to_py (line 3666) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____const__char__...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py (line 3721) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py
function PyObject (line 3724) | static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____...
function __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____char_______to_py (line 3737) | static void __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____c...
type __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py (line 3748) | struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____char_______to_py
type PyModuleDef (line 3824) | struct PyModuleDef
function CYTHON_SMALL_CODE (line 3910) | static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
function CYTHON_SMALL_CODE (line 3914) | static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
function CYTHON_SMALL_CODE (line 3955) | static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
function __Pyx_modinit_global_init_code (line 3978) | static int __Pyx_modinit_global_init_code(void) {
function __Pyx_modinit_variable_export_code (line 3987) | static int __Pyx_modinit_variable_export_code(void) {
function __Pyx_modinit_function_export_code (line 3995) | static int __Pyx_modinit_function_export_code(void) {
function __Pyx_modinit_type_init_code (line 4003) | static int __Pyx_modinit_type_init_code(void) {
function __Pyx_modinit_type_import_code (line 4032) | static int __Pyx_modinit_type_import_code(void) {
function __Pyx_modinit_variable_import_code (line 4040) | static int __Pyx_modinit_variable_import_code(void) {
function __Pyx_modinit_function_import_code (line 4048) | static int __Pyx_modinit_function_import_code(void) {
function __Pyx_PyMODINIT_FUNC (line 4077) | __Pyx_PyMODINIT_FUNC PyInit_io(void)
function CYTHON_SMALL_CODE (line 4082) | static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
function CYTHON_SMALL_CODE (line 4105) | static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, P...
function CYTHON_SMALL_CODE (line 4120) | static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CY...
function __Pyx_RefNannyAPIStruct (line 4556) | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modn...
function CYTHON_INLINE (line 4573) | static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate,...
function CYTHON_INLINE (line 4585) | static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, P...
function __Pyx_WriteUnraisable (line 4596) | static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int cl...
function PyObject (line 4639) | static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
function CYTHON_INLINE (line 4663) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, ...
function PyObject (line 4676) | static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
function CYTHON_INLINE (line 4691) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
function CYTHON_INLINE (line 4695) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject ...
function CYTHON_INLINE (line 4707) | static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj...
function CYTHON_INLINE (line 4719) | static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
function PyObject (line 4752) | static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObjec...
function CYTHON_INLINE (line 4871) | static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *fun...
function CYTHON_INLINE (line 4894) | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObj...
function CYTHON_UNUSED (line 4913) | static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* functi...
function CYTHON_INLINE (line 4943) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, ...
function PyObject (line 4963) | static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *ar...
function CYTHON_INLINE (line 4973) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function CYTHON_INLINE (line 4991) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function CYTHON_INLINE (line 5003) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
function __Pyx_Raise (line 5025) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
function __Pyx_Raise (line 5076) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, P...
function __Pyx__PyObject_AsDouble (line 5183) | static double __Pyx__PyObject_AsDouble(PyObject* obj) {
function __Pyx_PyObject_GetMethod (line 5223) | static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObj...
function PyObject (line 5319) | static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject*...
function PyObject (line 5324) | static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* met...
function CYTHON_INLINE (line 5337) | static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
function __Pyx_RaiseDoubleKeywordsError (line 5350) | static void __Pyx_RaiseDoubleKeywordsError(
function __Pyx_ParseOptionalKeywords (line 5364) | static int __Pyx_ParseOptionalKeywords(
function __Pyx_RaiseArgtupleInvalid (line 5466) | static void __Pyx_RaiseArgtupleInvalid(
function PyTypeObject (line 5492) | static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
function PyObject (line 5532) | static PyObject *
function __Pyx_CyFunction_set_doc (line 5552) | static int
function PyObject (line 5564) | static PyObject *
function __Pyx_CyFunction_set_name (line 5579) | static int
function PyObject (line 5599) | static PyObject *
function __Pyx_CyFunction_set_qualname (line 5605) | static int
function PyObject (line 5625) | static PyObject *
function PyObject (line 5635) | static PyObject *
function __Pyx_CyFunction_set_dict (line 5646) | static int
function PyObject (line 5666) | static PyObject *
function PyObject (line 5672) | static PyObject *
function PyObject (line 5678) | static PyObject *
function __Pyx_CyFunction_init_defaults (line 5685) | static int
function __Pyx_CyFunction_set_defaults (line 5707) | static int
function PyObject (line 5723) | static PyObject *
function __Pyx_CyFunction_set_kwdefaults (line 5737) | static int
function PyObject (line 5753) | static PyObject *
function __Pyx_CyFunction_set_annotations (line 5767) | static int
function PyObject (line 5783) | static PyObject *
function PyObject (line 5819) | static PyObject *
function PyObject (line 5837) | static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *m...
function __Pyx_CyFunction_clear (line 5869) | static int
function __Pyx__CyFunction_dealloc (line 5894) | static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
function __Pyx_CyFunction_dealloc (line 5901) | static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
function __Pyx_CyFunction_traverse (line 5906) | static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitpro...
function PyObject (line 5927) | static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *ob...
function PyObject (line 5943) | static PyObject*
function PyObject (line 5954) | static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *...
function CYTHON_INLINE (line 6008) | static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyO...
function PyObject (line 6011) | static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject ...
function __pyx_CyFunction_init (line 6094) | static int __pyx_CyFunction_init(void) {
function CYTHON_INLINE (line 6101) | static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func,...
function CYTHON_INLINE (line 6110) | static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *fu...
function CYTHON_INLINE (line 6115) | static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *f...
function CYTHON_INLINE (line 6120) | static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *...
function PyObject (line 6128) | static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, P...
function CYTHON_INLINE (line 6139) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObj...
function PyObject (line 6167) | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int l...
function PyObject (line 6232) | static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
function __Pyx_CLineForTraceback (line 6247) | static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
function __pyx_bisect_code_objects (line 6288) | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries...
function PyCodeObject (line 6309) | static PyCodeObject *__pyx_find_code_object(int code_line) {
function __pyx_insert_code_object (line 6323) | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_o...
function PyCodeObject (line 6371) | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
function __Pyx_AddTraceback (line 6423) | static void __Pyx_AddTraceback(const char *funcname, int c_line,
function CYTHON_INLINE (line 6475) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LON...
function CYTHON_INLINE (line 6506) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
function CYTHON_INLINE (line 6726) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
function __Pyx_InBases (line 6947) | static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
function CYTHON_INLINE (line 6955) | static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *...
function __Pyx_inner_PyErr_GivenExceptionMatches2 (line 6971) | static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObj...
function CYTHON_INLINE (line 6993) | static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObje...
function __Pyx_PyErr_GivenExceptionMatchesTuple (line 7001) | static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, Py...
function CYTHON_INLINE (line 7022) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err...
function CYTHON_INLINE (line 7034) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *er...
function __Pyx_check_binary_version (line 7046) | static int __Pyx_check_binary_version(void) {
function __Pyx_InitStrings (line 7062) | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
function CYTHON_INLINE (line 7094) | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_...
function CYTHON_INLINE (line 7097) | static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
function CYTHON_INLINE (line 7124) | static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObjec...
function CYTHON_INLINE (line 7166) | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
function CYTHON_INLINE (line 7171) | static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
function PyObject (line 7178) | static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* resul...
function CYTHON_INLINE (line 7247) | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
function CYTHON_INLINE (line 7309) | static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
function CYTHON_INLINE (line 7312) | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
FILE: clib/math.c
type PyObject (line 336) | typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *co...
type PyObject (line 337) | typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, ...
type Py_tss_t (line 378) | typedef int Py_tss_t;
function CYTHON_INLINE (line 379) | static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
function CYTHON_INLINE (line 383) | static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
function CYTHON_INLINE (line 388) | static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
function CYTHON_INLINE (line 391) | static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
function CYTHON_INLINE (line 394) | static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
function CYTHON_INLINE (line 398) | static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
function CYTHON_INLINE (line 401) | static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
type Py_hash_t (line 525) | typedef long Py_hash_t;
type __Pyx_PyAsyncMethodsStruct (line 548) | typedef struct {
function CYTHON_INLINE (line 562) | static CYTHON_INLINE float __PYX_NAN() {
type __Pyx_StringTabEntry (line 604) | typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const c...
function CYTHON_INLINE (line 625) | static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t l...
function CYTHON_INLINE (line 674) | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
function __Pyx_init_sys_getdefaultencoding_params (line 706) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function __Pyx_init_sys_getdefaultencoding_params (line 756) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function CYTHON_INLINE (line 788) | static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void...
type __Pyx_StructField_ (line 811) | struct __Pyx_StructField_
type __Pyx_TypeInfo (line 813) | typedef struct {
type __Pyx_StructField (line 823) | typedef struct __Pyx_StructField_ {
type __Pyx_BufFmt_StackElem (line 828) | typedef struct {
type __Pyx_BufFmt_Context (line 832) | typedef struct {
type __pyx_memoryview_obj (line 853) | struct __pyx_memoryview_obj
type __Pyx_memviewslice (line 854) | typedef struct {
type __pyx_atomic_int_type (line 899) | typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
type arrayobject (line 920) | struct arrayobject
type arrayobject (line 921) | typedef struct arrayobject arrayobject;
type __pyx_obj_4math_Matrix (line 923) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math___pyx_scope_struct__tolist (line 924) | struct __pyx_obj_4math___pyx_scope_struct__tolist
type __pyx_obj_4math___pyx_scope_struct_1_genexpr (line 925) | struct __pyx_obj_4math___pyx_scope_struct_1_genexpr
type __pyx_array_obj (line 926) | struct __pyx_array_obj
type __pyx_MemviewEnum_obj (line 927) | struct __pyx_MemviewEnum_obj
type __pyx_memoryview_obj (line 928) | struct __pyx_memoryview_obj
type __pyx_memoryviewslice_obj (line 929) | struct __pyx_memoryviewslice_obj
type __pyx_obj_4math_Matrix (line 938) | struct __pyx_obj_4math_Matrix {
type __pyx_obj_4math___pyx_scope_struct__tolist (line 953) | struct __pyx_obj_4math___pyx_scope_struct__tolist {
type __pyx_obj_4math___pyx_scope_struct_1_genexpr (line 968) | struct __pyx_obj_4math___pyx_scope_struct_1_genexpr {
type __pyx_array_obj (line 982) | struct __pyx_array_obj {
type __pyx_MemviewEnum_obj (line 1007) | struct __pyx_MemviewEnum_obj {
type __pyx_memoryview_obj (line 1020) | struct __pyx_memoryview_obj {
type __pyx_memoryviewslice_obj (line 1043) | struct __pyx_memoryviewslice_obj {
type __pyx_vtabstruct_array (line 1061) | struct __pyx_vtabstruct_array {
type __pyx_vtabstruct_array (line 1064) | struct __pyx_vtabstruct_array
type __pyx_vtabstruct_memoryview (line 1075) | struct __pyx_vtabstruct_memoryview {
type __pyx_vtabstruct_memoryview (line 1084) | struct __pyx_vtabstruct_memoryview
type __pyx_vtabstruct__memoryviewslice (line 1095) | struct __pyx_vtabstruct__memoryviewslice {
type __pyx_vtabstruct__memoryviewslice (line 1098) | struct __pyx_vtabstruct__memoryviewslice
type __Pyx_RefNannyAPIStruct (line 1106) | typedef struct {
function CYTHON_INLINE (line 1327) | static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject*...
type __pyx_memoryview_obj (line 1437) | struct __pyx_memoryview_obj
type __pyx_array_obj (line 1484) | struct __pyx_array_obj
function CYTHON_INLINE (line 1489) | static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s...
function CYTHON_INLINE (line 1493) | static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char ...
function CYTHON_INLINE (line 1497) | static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char ...
function CYTHON_INLINE (line 1572) | static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
function CYTHON_INLINE (line 1586) | static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
type __Pyx_ImportType_CheckSize (line 1641) | enum __Pyx_ImportType_CheckSize {
type __Pyx_ImportType_CheckSize (line 1646) | enum __Pyx_ImportType_CheckSize
type __Pyx_CodeObjectCacheEntry (line 1657) | typedef struct {
type __Pyx_CodeObjectCache (line 1661) | struct __Pyx_CodeObjectCache {
type __Pyx_CodeObjectCache (line 1666) | struct __Pyx_CodeObjectCache
type arraydescr (line 1678) | typedef struct arraydescr {
type arrayobject (line 1687) | struct arrayobject {
function CYTHON_INLINE (line 1718) | static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ss...
type arraydescr (line 1752) | struct arraydescr
function CYTHON_INLINE (line 1754) | static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
function CYTHON_INLINE (line 1766) | static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
type __Pyx_Buf_DimInfo (line 1800) | typedef struct {
type __Pyx_Buffer (line 1803) | typedef struct {
type __Pyx_LocalBuf_ND (line 1807) | typedef struct {
type PyObject (line 1856) | typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *,...
type __Pyx_ExcInfoStruct (line 1860) | typedef struct {
type __pyx_CoroutineObject (line 1866) | typedef struct {
type __pyx_array_obj (line 1953) | struct __pyx_array_obj
type __pyx_memoryview_obj (line 1954) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1955) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1956) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1957) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1957) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1958) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1959) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 1960) | struct __pyx_memoryview_obj
type __pyx_memoryviewslice_obj (line 1961) | struct __pyx_memoryviewslice_obj
type __pyx_memoryviewslice_obj (line 1962) | struct __pyx_memoryviewslice_obj
type __pyx_obj_4math_Matrix (line 2010) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2010) | struct __pyx_obj_4math_Matrix
type __pyx_array_obj (line 2011) | struct __pyx_array_obj
type __pyx_memoryview_obj (line 2017) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2017) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2022) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2023) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2024) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2025) | struct __pyx_memoryview_obj
type __pyx_MemviewEnum_obj (line 2043) | struct __pyx_MemviewEnum_obj
type __pyx_obj_4math_Matrix (line 2268) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2269) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2270) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2271) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2272) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2273) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2275) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2276) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2277) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2278) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2281) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math_Matrix (line 2281) | struct __pyx_obj_4math_Matrix
type __pyx_array_obj (line 2284) | struct __pyx_array_obj
type __pyx_array_obj (line 2285) | struct __pyx_array_obj
type __pyx_array_obj (line 2286) | struct __pyx_array_obj
type __pyx_array_obj (line 2287) | struct __pyx_array_obj
type __pyx_array_obj (line 2288) | struct __pyx_array_obj
type __pyx_array_obj (line 2289) | struct __pyx_array_obj
type __pyx_array_obj (line 2290) | struct __pyx_array_obj
type __pyx_array_obj (line 2291) | struct __pyx_array_obj
type __pyx_MemviewEnum_obj (line 2294) | struct __pyx_MemviewEnum_obj
type __pyx_MemviewEnum_obj (line 2295) | struct __pyx_MemviewEnum_obj
type __pyx_MemviewEnum_obj (line 2296) | struct __pyx_MemviewEnum_obj
type __pyx_MemviewEnum_obj (line 2297) | struct __pyx_MemviewEnum_obj
type __pyx_memoryview_obj (line 2298) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2299) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2300) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2301) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2302) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2303) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2304) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2305) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2306) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2307) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2308) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2309) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2310) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2311) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2312) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2313) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2314) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2315) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2316) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2317) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 2318) | struct __pyx_memoryview_obj
type __pyx_memoryviewslice_obj (line 2321) | struct __pyx_memoryviewslice_obj
type __pyx_memoryviewslice_obj (line 2322) | struct __pyx_memoryviewslice_obj
function __pyx_pw_4math_6Matrix_1__cinit__ (line 2377) | static int __pyx_pw_4math_6Matrix_1__cinit__(PyObject *__pyx_v_self, PyO...
function __pyx_pf_4math_6Matrix___cinit__ (line 2440) | static int __pyx_pf_4math_6Matrix___cinit__(struct __pyx_obj_4math_Matri...
function PyObject (line 2656) | static PyObject *__pyx_pw_4math_6Matrix_5shape_1__get__(PyObject *__pyx_...
function PyObject (line 2667) | static PyObject *__pyx_pf_4math_6Matrix_5shape___get__(struct __pyx_obj_...
function PyObject (line 2730) | static PyObject *__pyx_pw_4math_6Matrix_3src_1__get__(PyObject *__pyx_v_...
function PyObject (line 2741) | static PyObject *__pyx_pf_4math_6Matrix_3src___get__(struct __pyx_obj_4m...
function PyObject (line 2783) | static PyObject *__pyx_pw_4math_6Matrix_3__getitem__(PyObject *__pyx_v_s...
function PyObject (line 2794) | static PyObject *__pyx_pf_4math_6Matrix_2__getitem__(struct __pyx_obj_4m...
function Py_ssize_t (line 2843) | static Py_ssize_t __pyx_pw_4math_6Matrix_5__len__(PyObject *__pyx_v_self) {
function Py_ssize_t (line 2854) | static Py_ssize_t __pyx_pf_4math_6Matrix_4__len__(struct __pyx_obj_4math...
function PyObject (line 2907) | static PyObject *__pyx_pw_4math_6Matrix_7reshape(PyObject *__pyx_v_self,...
function PyObject (line 2918) | static PyObject *__pyx_pf_4math_6Matrix_6reshape(struct __pyx_obj_4math_...
function PyObject (line 3088) | static PyObject *__pyx_pw_4math_6Matrix_9tolist(PyObject *__pyx_v_self, ...
function PyObject (line 3108) | static PyObject *__pyx_pf_4math_6Matrix_6tolist_genexpr(PyObject *__pyx_...
function PyObject (line 3141) | static PyObject *__pyx_gb_4math_6Matrix_6tolist_2generator(__pyx_Corouti...
function PyObject (line 3286) | static PyObject *__pyx_pf_4math_6Matrix_8tolist(struct __pyx_obj_4math_M...
function PyObject (line 3369) | static PyObject *__pyx_pw_4math_6Matrix_5_rows_1__get__(PyObject *__pyx_...
function PyObject (line 3380) | static PyObject *__pyx_pf_4math_6Matrix_5_rows___get__(struct __pyx_obj_...
function PyObject (line 3413) | static PyObject *__pyx_pw_4math_6Matrix_5_cols_1__get__(PyObject *__pyx_...
function PyObject (line 3424) | static PyObject *__pyx_pf_4math_6Matrix_5_cols___get__(struct __pyx_obj_...
function PyObject (line 3457) | static PyObject *__pyx_pw_4math_6Matrix_4_src_1__get__(PyObject *__pyx_v...
function PyObject (line 3468) | static PyObject *__pyx_pf_4math_6Matrix_4_src___get__(struct __pyx_obj_4...
function PyObject (line 3492) | static PyObject *__pyx_pw_4math_6Matrix_11__reduce_cython__(PyObject *__...
function PyObject (line 3503) | static PyObject *__pyx_pf_4math_6Matrix_10__reduce_cython__(CYTHON_UNUSE...
function PyObject (line 3546) | static PyObject *__pyx_pw_4math_6Matrix_13__setstate_cython__(PyObject *...
function PyObject (line 3557) | static PyObject *__pyx_pf_4math_6Matrix_12__setstate_cython__(CYTHON_UNU...
function PyObject (line 3600) | static PyObject *__pyx_f_4math_dot(struct __pyx_obj_4math_Matrix *__pyx_...
function PyObject (line 4146) | static PyObject *__pyx_pw_4math_1dot(PyObject *__pyx_self, PyObject *__p...
function PyObject (line 4211) | static PyObject *__pyx_pf_4math_dot(CYTHON_UNUSED PyObject *__pyx_self, ...
function CYTHON_UNUSED (line 4244) | static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(...
function __pyx_pf_7cpython_5array_5array___getbuffer__ (line 4255) | static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__...
function CYTHON_UNUSED (line 4488) | static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuff...
function __pyx_pf_7cpython_5array_5array_2__releasebuffer__ (line 4497) | static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UN...
function CYTHON_INLINE (line 4530) | static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobj...
function CYTHON_INLINE (line 4629) | static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobje...
function CYTHON_INLINE (line 4697) | static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobje...
function CYTHON_INLINE (line 4777) | static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__p...
function CYTHON_INLINE (line 4848) | static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__py...
function __pyx_array___cinit__ (line 4881) | static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx...
function __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__ (line 5006) | static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(s...
function CYTHON_UNUSED (line 5626) | static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, P...
function __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__ (line 5637) | static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffe...
function __pyx_array___dealloc__ (line 5930) | static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
function __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__ (line 5939) | static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc...
function PyObject (line 6061) | static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__...
function PyObject (line 6072) | static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(...
function PyObject (line 6119) | static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v...
function Py_ssize_t (line 6198) | static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
function Py_ssize_t (line 6209) | static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__l...
function PyObject (line 6248) | static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObjec...
function PyObject (line 6259) | static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__ge...
function PyObject (line 6313) | static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObjec...
function PyObject (line 6324) | static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__g...
function __pyx_array___setitem__ (line 6378) | static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__p...
function __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__ (line 6389) | static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem...
function PyObject (line 6435) | static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx...
function PyObject (line 6446) | static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED st...
function PyObject (line 6489) | static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__p...
function PyObject (line 6500) | static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED...
type __pyx_array_obj (line 6542) | struct __pyx_array_obj
type __pyx_array_obj (line 6543) | struct __pyx_array_obj
type __pyx_array_obj (line 6544) | struct __pyx_array_obj
type __pyx_array_obj (line 6593) | struct __pyx_array_obj
type __pyx_array_obj (line 6657) | struct __pyx_array_obj
function __pyx_MemviewEnum___init__ (line 6716) | static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *...
function __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__ (line 6764) | static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init...
function PyObject (line 6806) | static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
function PyObject (line 6817) | static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_...
function PyObject (line 6857) | static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject ...
function PyObject (line 6868) | static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __p...
function PyObject (line 7089) | static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObjec...
function PyObject (line 7100) | static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct ...
function __pyx_memoryview___cinit__ (line 7229) | static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *...
function __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__ (line 7306) | static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_...
function __pyx_memoryview___dealloc__ (line 7602) | static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
function __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__ (line 7611) | static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview...
type __pyx_memoryview_obj (line 7792) | struct __pyx_memoryview_obj
function PyObject (line 7929) | static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, Py...
function PyObject (line 7940) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function __pyx_memoryview___setitem__ (line 8115) | static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject...
function __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__ (line 8126) | static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_...
function PyObject (line 8338) | static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *...
function PyObject (line 8545) | static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_...
function PyObject (line 8628) | static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __p...
function PyObject (line 8913) | static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryvie...
function PyObject (line 8971) | static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_me...
function PyObject (line 9245) | static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_m...
function CYTHON_UNUSED (line 9483) | static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_se...
function __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__ (line 9494) | static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_...
function PyObject (line 9824) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__...
function PyObject (line 9835) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(...
function PyObject (line 9907) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__ge...
function PyObject (line 9918) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get...
function PyObject (line 9960) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__g...
function PyObject (line 9971) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___ge...
function PyObject (line 10038) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1_...
function PyObject (line 10049) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___...
function PyObject (line 10149) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffset...
function PyObject (line 10160) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffset...
function PyObject (line 10264) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__ge...
function PyObject (line 10275) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get...
function PyObject (line 10324) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1...
function PyObject (line 10335) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize__...
function PyObject (line 10384) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__...
function PyObject (line 10395) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___g...
function PyObject (line 10454) | static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__ge...
function PyObject (line 10465) | static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get...
function Py_ssize_t (line 10592) | static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
function Py_ssize_t (line 10603) | static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memo...
function PyObject (line 10672) | static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
function PyObject (line 10683) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function PyObject (line 10771) | static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
function PyObject (line 10782) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function PyObject (line 10847) | static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CY...
function PyObject (line 10858) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function PyObject (line 10918) | static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CY...
function PyObject (line 10929) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function PyObject (line 10989) | static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UN...
function PyObject (line 11000) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function PyObject (line 11080) | static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, C...
function PyObject (line 11091) | static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memor...
function PyObject (line 11170) | static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *...
function PyObject (line 11181) | static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUS...
function PyObject (line 11224) | static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject...
function PyObject (line 11235) | static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_U...
function PyObject (line 11277) | static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_f...
function CYTHON_INLINE (line 11365) | static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
function PyObject (line 11404) | static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
function PyObject (line 11858) | static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets...
type __pyx_memoryview_obj (line 11943) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 11943) | struct __pyx_memoryview_obj
type __pyx_memoryviewslice_obj (line 11950) | struct __pyx_memoryviewslice_obj
type __pyx_memoryview_obj (line 11960) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 11965) | struct __pyx_memoryview_obj
type __pyx_memoryviewslice_obj (line 12032) | struct __pyx_memoryviewslice_obj
type __pyx_memoryview_obj (line 12444) | struct __pyx_memoryview_obj
type __pyx_memoryview_obj (line 12485) | struct __pyx_memoryview_obj
function __pyx_memoryview_slice_memviewslice (line 12520) | static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx...
function __pyx_memslice_transpose (line 13607) | static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
function __pyx_memoryviewslice___dealloc__ (line 13780) | static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
function __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__ (line 13789) | static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memo...
function PyObject (line 13822) | static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __p...
function PyObject (line 13905) | static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __...
function PyObject (line 13987) | static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base...
function PyObject (line 13998) | static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base...
function PyObject (line 14038) | static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObj...
function PyObject (line 14049) | static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON...
function PyObject (line 14092) | static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyO...
function PyObject (line 14103) | static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYT...
function PyObject (line 14145) | static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_m...
function __Pyx_memviewslice (line 14528) | static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(st...
function __pyx_memoryview_slice_copy (line 14628) | static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__p...
function PyObject (line 14754) | static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_ob...
function PyObject (line 14811) | static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_me...
function Py_ssize_t (line 14934) | static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
function __pyx_get_best_slice_order (line 15000) | static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslic...
function _copy_strided_to_strided (line 15190) | static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t ...
function copy_strided_to_strided (line 15427) | static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __P...
function Py_ssize_t (line 15457) | static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__...
function Py_ssize_t (line 15529) | static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_sh...
type __pyx_memoryview_obj (line 15660) | struct __pyx_memoryview_obj
function __pyx_memoryview_err_extents (line 15903) | static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_...
function __pyx_memoryview_err_dim (line 15988) | static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx...
function __pyx_memoryview_err (line 16069) | static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_m...
function __pyx_memoryview_copy_contents (line 16176) | static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src...
function __pyx_memoryview_broadcast_leading (line 16752) | static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx...
function __pyx_memoryview_refcount_copying (line 16865) | static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_...
function __pyx_memoryview_refcount_objects_in_slice_with_gil (line 16915) | static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__...
function __pyx_memoryview_refcount_objects_in_slice (line 16954) | static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_dat...
function __pyx_memoryview_slice_assign_scalar (line 17086) | static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__p...
function __pyx_memoryview__slice_assign_scalar (line 17134) | static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py...
function PyObject (line 17266) | static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyO...
function PyObject (line 17336) | static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTH...
function PyObject (line 17524) | static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum...
function PyObject (line 17645) | static PyObject *__pyx_tp_new_4math_Matrix(PyTypeObject *t, PyObject *a,...
function __pyx_tp_dealloc_4math_Matrix (line 17663) | static void __pyx_tp_dealloc_4math_Matrix(PyObject *o) {
function __pyx_tp_traverse_4math_Matrix (line 17675) | static int __pyx_tp_traverse_4math_Matrix(PyObject *o, visitproc v, void...
function __pyx_tp_clear_4math_Matrix (line 17684) | static int __pyx_tp_clear_4math_Matrix(PyObject *o) {
function PyObject (line 17692) | static PyObject *__pyx_sq_item_4math_Matrix(PyObject *o, Py_ssize_t i) {
function PyObject (line 17700) | static PyObject *__pyx_getprop_4math_6Matrix_shape(PyObject *o, CYTHON_U...
function PyObject (line 17704) | static PyObject *__pyx_getprop_4math_6Matrix_src(PyObject *o, CYTHON_UNU...
function PyObject (line 17708) | static PyObject *__pyx_getprop_4math_6Matrix__rows(PyObject *o, CYTHON_U...
function PyObject (line 17712) | static PyObject *__pyx_getprop_4math_6Matrix__cols(PyObject *o, CYTHON_U...
function PyObject (line 17716) | static PyObject *__pyx_getprop_4math_6Matrix__src(PyObject *o, CYTHON_UN...
type PyGetSetDef (line 17728) | struct PyGetSetDef
type __pyx_obj_4math_Matrix (line 17759) | struct __pyx_obj_4math_Matrix
type __pyx_obj_4math___pyx_scope_struct__tolist (line 17814) | struct __pyx_obj_4math___pyx_scope_struct__tolist
function PyObject (line 17817) | static PyObject *__pyx_tp_new_4math___pyx_scope_struct__tolist(PyTypeObj...
function __pyx_tp_dealloc_4math___pyx_scope_struct__tolist (line 17831) | static void __pyx_tp_dealloc_4math___pyx_scope_struct__tolist(PyObject *...
function __pyx_tp_traverse_4math___pyx_scope_struct__tolist (line 17842) | static int __pyx_tp_traverse_4math___pyx_scope_struct__tolist(PyObject *...
function __pyx_tp_clear_4math___pyx_scope_struct__tolist (line 17851) | static int __pyx_tp_clear_4math___pyx_scope_struct__tolist(PyObject *o) {
type __pyx_obj_4math___pyx_scope_struct__tolist (line 17863) | struct __pyx_obj_4math___pyx_scope_struct__tolist
type __pyx_obj_4math___pyx_scope_struct_1_genexpr (line 17918) | struct __pyx_obj_4math___pyx_scope_struct_1_genexpr
function PyObject (line 17921) | static PyObject *__pyx_tp_new_4math___pyx_scope_struct_1_genexpr(PyTypeO...
function __pyx_tp_dealloc_4math___pyx_scope_struct_1_genexpr (line 17935) | static void __pyx_tp_dealloc_4math___pyx_scope_struct_1_genexpr(PyObject...
function __pyx_tp_traverse_4math___pyx_scope_struct_1_genexpr (line 17947) | static int __pyx_tp_traverse_4math___pyx_scope_struct_1_genexpr(PyObject...
type __pyx_obj_4math___pyx_scope_struct_1_genexpr (line 17962) | struct __pyx_obj_4math___pyx_scope_struct_1_genexpr
type __pyx_vtabstruct_array (line 18016) | struct __pyx_vtabstruct_array
function PyObject (line 18018) | static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObje...
function __pyx_tp_dealloc_array (line 18038) | static void __pyx_tp_dealloc_array(PyObject *o) {
function PyObject (line 18057) | static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
function __pyx_mp_ass_subscript_array (line 18065) | static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObje...
function PyObject (line 18076) | static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
function PyObject (line 18085) | static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_U...
type PyGetSetDef (line 18096) | struct PyGetSetDef
type __pyx_array_obj (line 18140) | struct __pyx_array_obj
function PyObject (line 18195) | static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObje...
function __pyx_tp_dealloc_Enum (line 18209) | static void __pyx_tp_dealloc_Enum(PyObject *o) {
function __pyx_tp_traverse_Enum (line 18221) | static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
function __pyx_tp_clear_Enum (line 18230) | static int __pyx_tp_clear_Enum(PyObject *o) {
type __pyx_MemviewEnum_obj (line 18248) | struct __pyx_MemviewEnum_obj
type __pyx_vtabstruct_memoryview (line 18302) | struct __pyx_vtabstruct_memoryview
function PyObject (line 18304) | static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, P...
function __pyx_tp_dealloc_memoryview (line 18326) | static void __pyx_tp_dealloc_memoryview(PyObject *o) {
function __pyx_tp_traverse_memoryview (line 18348) | static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *...
function __pyx_tp_clear_memoryview (line 18366) | static int __pyx_tp_clear_memoryview(PyObject *o) {
function PyObject (line 18381) | static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
function __pyx_mp_ass_subscript_memoryview (line 18389) | static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, P...
function PyObject (line 18400) | static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UN...
function PyObject (line 18404) | static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON...
function PyObject (line 18408) | static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHO...
function PyObject (line 18412) | static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYT...
function PyObject (line 18416) | static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, ...
function PyObject (line 18420) | static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON...
function PyObject (line 18424) | static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CY...
function PyObject (line 18428) | static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTH...
function PyObject (line 18432) | static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON...
type PyGetSetDef (line 18446) | struct PyGetSetDef
type __pyx_memoryview_obj (line 18498) | struct __pyx_memoryview_obj
type __pyx_vtabstruct__memoryviewslice (line 18552) | struct __pyx_vtabstruct__memoryviewslice
function PyObject (line 18554) | static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject...
function __pyx_tp_dealloc__memoryviewslice (line 18565) | static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
function __pyx_tp_traverse__memoryviewslice (line 18586) | static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, ...
function __pyx_tp_clear__memoryviewslice (line 18596) | static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
function PyObject (line 18607) | static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, C...
type PyGetSetDef (line 18617) | struct PyGetSetDef
type __pyx_memoryviewslice_obj (line 18625) | struct __pyx_memoryviewslice_obj
type PyModuleDef (line 18704) | struct PyModuleDef
function CYTHON_SMALL_CODE (line 18843) | static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
function CYTHON_SMALL_CODE (line 18857) | static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
function CYTHON_SMALL_CODE (line 19143) | static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
function __Pyx_modinit_global_init_code (line 19163) | static int __Pyx_modinit_global_init_code(void) {
function __Pyx_modinit_variable_export_code (line 19176) | static int __Pyx_modinit_variable_export_code(void) {
function __Pyx_modinit_function_export_code (line 19184) | static int __Pyx_modinit_function_export_code(void) {
function __Pyx_modinit_type_init_code (line 19192) | static int __Pyx_modinit_type_init_code(void) {
function __Pyx_modinit_type_import_code (line 19266) | static int __Pyx_modinit_type_import_code(void) {
function __Pyx_modinit_variable_import_code (line 19295) | static int __Pyx_modinit_variable_import_code(void) {
function __Pyx_modinit_function_import_code (line 19303) | static int __Pyx_modinit_function_import_code(void) {
function __Pyx_PyMODINIT_FUNC (line 19332) | __Pyx_PyMODINIT_FUNC PyInit_math(void)
function CYTHON_SMALL_CODE (line 19337) | static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
function CYTHON_SMALL_CODE (line 19360) | static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, P...
function CYTHON_SMALL_CODE (line 19375) | static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CY...
function __Pyx_RefNannyAPIStruct (line 19730) | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modn...
function CYTHON_INLINE (line 19747) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, ...
function PyObject (line 19760) | static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
function __Pyx_RaiseDoubleKeywordsError (line 19774) | static void __Pyx_RaiseDoubleKeywordsError(
function __Pyx_ParseOptionalKeywords (line 19788) | static int __Pyx_ParseOptionalKeywords(
function __Pyx_RaiseArgtupleInvalid (line 19890) | static void __Pyx_RaiseArgtupleInvalid(
function CYTHON_INLINE (line 19916) | static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *typ...
function PyObject (line 19929) | static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
function CYTHON_INLINE (line 19936) | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, P...
function CYTHON_INLINE (line 19954) | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, ...
function CYTHON_INLINE (line 19972) | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssi...
function CYTHON_INLINE (line 20017) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
function CYTHON_INLINE (line 20021) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject ...
function CYTHON_INLINE (line 20033) | static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj...
function CYTHON_INLINE (line 20045) | static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
function CYTHON_INLINE (line 20078) | static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *fun...
function PyObject (line 20101) | static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObjec...
function CYTHON_INLINE (line 20220) | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObj...
function CYTHON_UNUSED (line 20239) | static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* functi...
function CYTHON_INLINE (line 20269) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, ...
function PyObject (line 20289) | static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *ar...
function CYTHON_INLINE (line 20299) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function CYTHON_INLINE (line 20317) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function PyObject (line 20329) | static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
function PyObject (line 20347) | static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
function CYTHON_INLINE (line 20357) | static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expec...
function CYTHON_INLINE (line 20363) | static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t inde...
function CYTHON_INLINE (line 20370) | static CYTHON_INLINE int __Pyx_IterFinish(void) {
function __Pyx_IternextUnpackEndCheck (line 20405) | static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t exp...
function CYTHON_INLINE (line 20417) | static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varnam...
function PyObject (line 20423) | static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHO...
function CYTHON_INLINE (line 20546) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
function CYTHON_INLINE (line 20644) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
function CYTHON_INLINE (line 20666) | static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate,...
function CYTHON_INLINE (line 20678) | static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, P...
function __Pyx_Raise (line 20690) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
function __Pyx_Raise (line 20741) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, P...
function CYTHON_INLINE (line 20848) | static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
function __Pyx_BufFmt_Init (line 20859) | static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
function __Pyx_BufFmt_ParseNumber (line 20886) | static int __Pyx_BufFmt_ParseNumber(const char** ts) {
function __Pyx_BufFmt_ExpectNumber (line 20901) | static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
function __Pyx_BufFmt_RaiseUnexpectedChar (line 20908) | static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
function __Pyx_BufFmt_TypeCharToStandardSize (line 20936) | static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_comple...
function __Pyx_BufFmt_TypeCharToNativeSize (line 20954) | static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
type __Pyx_st_short (line 20973) | typedef struct { char c; short x; } __Pyx_st_short;
type __Pyx_st_int (line 20974) | typedef struct { char c; int x; } __Pyx_st_int;
type __Pyx_st_long (line 20975) | typedef struct { char c; long x; } __Pyx_st_long;
type __Pyx_st_float (line 20976) | typedef struct { char c; float x; } __Pyx_st_float;
type __Pyx_st_double (line 20977) | typedef struct { char c; double x; } __Pyx_st_double;
type __Pyx_st_longdouble (line 20978) | typedef struct { char c; long double x; } __Pyx_st_longdouble;
type __Pyx_st_void_p (line 20979) | typedef struct { char c; void *x; } __Pyx_st_void_p;
type __Pyx_st_longlong (line 20981) | typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
function __Pyx_BufFmt_TypeCharToAlignment (line 20983) | static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED in...
type __Pyx_pad_short (line 21005) | typedef struct { short x; char c; } __Pyx_pad_short;
type __Pyx_pad_int (line 21006) | typedef struct { int x; char c; } __Pyx_pad_int;
type __Pyx_pad_long (line 21007) | typedef struct { long x; char c; } __Pyx_pad_long;
type __Pyx_pad_float (line 21008) | typedef struct { float x; char c; } __Pyx_pad_float;
type __Pyx_pad_double (line 21009) | typedef struct { double x; char c; } __Pyx_pad_double;
type __Pyx_pad_longdouble (line 21010) | typedef struct { long double x; char c; } __Pyx_pad_longdouble;
type __Pyx_pad_void_p (line 21011) | typedef struct { void *x; char c; } __Pyx_pad_void_p;
type __Pyx_pad_longlong (line 21013) | typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
function __Pyx_BufFmt_TypeCharToPadding (line 21015) | static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int ...
function __Pyx_BufFmt_TypeCharToGroup (line 21033) | static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
function __Pyx_BufFmt_RaiseExpected (line 21054) | static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
function __Pyx_BufFmt_ProcessTypeChunk (line 21078) | static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
function PyObject (line 21180) | static PyObject *
function CYTHON_INLINE (line 21361) | static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
function __Pyx_ZeroBuffer (line 21366) | static void __Pyx_ZeroBuffer(Py_buffer* buf) {
function __Pyx__GetBufferAndValidate (line 21373) | static int __Pyx__GetBufferAndValidate(
function __Pyx_init_memviewslice (line 21408) | static int
function __pyx_fatalerror (line 21460) | static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
function CYTHON_INLINE (line 21472) | static CYTHON_INLINE int
function CYTHON_INLINE (line 21482) | static CYTHON_INLINE int
function CYTHON_INLINE (line 21492) | static CYTHON_INLINE void
function CYTHON_INLINE (line 21513) | static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
function CYTHON_INLINE (line 21542) | static CYTHON_INLINE void* __Pyx_BufPtrFull1d_imp(void* buf, Py_ssize_t ...
function __Pyx__ArgTypeTest (line 21550) | static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const c...
function CYTHON_INLINE (line 21571) | static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2...
function CYTHON_INLINE (line 21618) | static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* ...
function CYTHON_INLINE (line 21720) | static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ss...
function CYTHON_INLINE (line 21728) | static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
function CYTHON_INLINE (line 21741) | static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
function __Pyx_PyErr_ExceptionMatchesTuple (line 21775) | static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObjec...
function CYTHON_INLINE (line 21788) | static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadSta...
function PyObject (line 21799) | static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
function CYTHON_INLINE (line 21808) | static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, ...
function CYTHON_INLINE (line 21814) | static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
function _PyErr_StackItem (line 21820) | static _PyErr_StackItem *
function CYTHON_INLINE (line 21835) | static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, Py...
function CYTHON_INLINE (line 21850) | static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, P...
function __Pyx_GetException (line 21878) | static int __Pyx_GetException(PyObject **type, PyObject **value, PyObjec...
function CYTHON_INLINE (line 21950) | static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, Py...
function CYTHON_INLINE (line 21973) | static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject ...
function PyObject (line 21984) | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int l...
function __Pyx_InBases (line 22050) | static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
function CYTHON_INLINE (line 22058) | static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *...
function __Pyx_inner_PyErr_GivenExceptionMatches2 (line 22074) | static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObj...
function CYTHON_INLINE (line 22096) | static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObje...
function __Pyx_PyErr_GivenExceptionMatchesTuple (line 22104) | static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, Py...
function CYTHON_INLINE (line 22125) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err...
function CYTHON_INLINE (line 22137) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *er...
function CYTHON_INLINE (line 22149) | static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varna...
function __Pyx_div_long (line 22154) | static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
function __Pyx_WriteUnraisable (line 22162) | static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int cl...
function PyObject (line 22204) | static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
function CYTHON_INLINE (line 22218) | static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
function PyObject (line 22237) | static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, P...
function CYTHON_INLINE (line 22248) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObj...
function PyObject (line 22277) | static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* ...
function __Pyx_setup_reduce_is_named (line 22286) | static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
function __Pyx_setup_reduce (line 22302) | static int __Pyx_setup_reduce(PyObject* type_obj) {
function __Pyx_SetVtable (line 22362) | static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
function PyTypeObject (line 22382) | static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *modu...
function __Pyx_CLineForTraceback (line 22442) | static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
function __pyx_bisect_code_objects (line 22483) | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries...
function PyCodeObject (line 22504) | static PyCodeObject *__pyx_find_code_object(int code_line) {
function __pyx_insert_code_object (line 22518) | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_o...
function PyCodeObject (line 22566) | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
function __Pyx_AddTraceback (line 22618) | static void __Pyx_AddTraceback(const char *funcname, int c_line,
function __Pyx_GetBuffer (line 22648) | static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
function __Pyx_ReleaseBuffer (line 22656) | static void __Pyx_ReleaseBuffer(Py_buffer *view) {
function __pyx_memviewslice_is_contig (line 22672) | static int
function __pyx_get_array_memory_extents (line 22694) | static void
function __pyx_slices_overlap (line 22718) | static int
function CYTHON_INLINE (line 22730) | static CYTHON_INLINE PyObject *
function CYTHON_INLINE (line 22743) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
function CYTHON_INLINE (line 22774) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
function __Pyx_memviewslice (line 22827) | static __Pyx_memviewslice
function PyTypeObject (line 23461) | static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
function __Pyx_PyObject_GetMethod (line 23500) | static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObj...
function PyObject (line 23596) | static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject*...
function PyObject (line 23601) | static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* met...
function __Pyx_PyGen__FetchStopIterationValue (line 23617) | static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadSt...
function CYTHON_INLINE (line 23696) | static CYTHON_INLINE
function __Pyx__Coroutine_AlreadyRunningError (line 23710) | static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_Cor...
function __Pyx__Coroutine_NotStartedError (line 23727) | static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
function __Pyx__Coroutine_AlreadyTerminatedError (line 23744) | static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObje...
function PyObject (line 23759) | static
function CYTHON_INLINE (line 23815) | static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_Ex...
function CYTHON_INLINE (line 23826) | static CYTHON_INLINE
function CYTHON_INLINE (line 23842) | static CYTHON_INLINE
function PyObject (line 23852) | static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
function __Pyx_Coroutine_CloseIter (line 23902) | static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObjec...
function PyObject (line 23952) | static PyObject *__Pyx_Generator_Next(PyObject *self) {
function PyObject (line 23984) | static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNU...
function PyObject (line 23987) | static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
function PyObject (line 24033) | static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, P...
function PyObject (line 24095) | static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
function CYTHON_INLINE (line 24103) | static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfo...
function __Pyx_Coroutine_traverse (line 24109) | static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitpro...
function __Pyx_Coroutine_clear (line 24115) | static int __Pyx_Coroutine_clear(PyObject *self) {
function __Pyx_Coroutine_dealloc (line 24132) | static void __Pyx_Coroutine_dealloc(PyObject *self) {
function __Pyx_Coroutine_del (line 24161) | static void __Pyx_Coroutine_del(PyObject *self) {
function PyObject (line 24257) | static PyObject *
function __Pyx_Coroutine_set_name (line 24265) | static int
function PyObject (line 24285) | static PyObject *
function __Pyx_Coroutine_set_qualname (line 24293) | static int
function __pyx_CoroutineObject (line 24313) | static __pyx_CoroutineObject *__Pyx__Coroutine_New(
function __pyx_CoroutineObject (line 24321) | static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
function PyObject (line 24351) | static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const ch...
function PyObject (line 24396) | static PyObject* __Pyx_patch_abc_module(PyObject *module) {
function __Pyx_patch_abc (line 24411) | static int __Pyx_patch_abc(void) {
function __pyx_Generator_init (line 24529) | static int __pyx_Generator_init(void) {
function __pyx_typeinfo_cmp (line 24540) | static int
function __pyx_check_strides (line 24581) | static int
function __pyx_check_suboffsets (line 24634) | static int
function __pyx_verify_contig (line 24657) | static int
function __Pyx_ValidateAndInit_memviewslice (line 24689) | static int __Pyx_ValidateAndInit_memviewslice(
function CYTHON_INLINE (line 24763) | static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlic...
function __Pyx_check_binary_version (line 24786) | static int __Pyx_check_binary_version(void) {
function __Pyx_InitStrings (line 24802) | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
function CYTHON_INLINE (line 24834) | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_...
function CYTHON_INLINE (line 24837) | static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
function CYTHON_INLINE (line 24864) | static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObjec...
function CYTHON_INLINE (line 24906) | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
function CYTHON_INLINE (line 24911) | static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
function PyObject (line 24918) | static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* resul...
function CYTHON_INLINE (line 24987) | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
function CYTHON_INLINE (line 25049) | static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
function CYTHON_INLINE (line 25052) | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
FILE: clib/string_transfer.c
type PyObject (line 336) | typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *co...
type PyObject (line 337) | typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, ...
type Py_tss_t (line 378) | typedef int Py_tss_t;
function CYTHON_INLINE (line 379) | static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
function CYTHON_INLINE (line 383) | static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
function CYTHON_INLINE (line 388) | static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
function CYTHON_INLINE (line 391) | static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
function CYTHON_INLINE (line 394) | static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
function CYTHON_INLINE (line 398) | static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
function CYTHON_INLINE (line 401) | static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
type Py_hash_t (line 525) | typedef long Py_hash_t;
type __Pyx_PyAsyncMethodsStruct (line 548) | typedef struct {
function CYTHON_INLINE (line 562) | static CYTHON_INLINE float __PYX_NAN() {
type __Pyx_StringTabEntry (line 602) | typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const c...
function CYTHON_INLINE (line 623) | static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t l...
function CYTHON_INLINE (line 672) | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
function __Pyx_init_sys_getdefaultencoding_params (line 704) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function __Pyx_init_sys_getdefaultencoding_params (line 754) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function CYTHON_INLINE (line 786) | static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void...
type arrayobject (line 809) | struct arrayobject
type arrayobject (line 810) | typedef struct arrayobject arrayobject;
type __Pyx_RefNannyAPIStruct (line 819) | typedef struct {
type __Pyx_ImportType_CheckSize (line 1048) | enum __Pyx_ImportType_CheckSize {
type __Pyx_ImportType_CheckSize (line 1053) | enum __Pyx_ImportType_CheckSize
function CYTHON_INLINE (line 1064) | static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject*...
type __Pyx_CodeObjectCacheEntry (line 1087) | typedef struct {
type __Pyx_CodeObjectCache (line 1091) | struct __Pyx_CodeObjectCache {
type __Pyx_CodeObjectCache (line 1096) | struct __Pyx_CodeObjectCache
type arraydescr (line 1108) | typedef struct arraydescr {
type arrayobject (line 1117) | struct arrayobject {
function CYTHON_INLINE (line 1148) | static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ss...
type arraydescr (line 1182) | struct arraydescr
function CYTHON_INLINE (line 1184) | static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
function CYTHON_INLINE (line 1196) | static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
function PY_LONG_LONG (line 1426) | static PY_LONG_LONG __pyx_f_15string_transfer_str2int(char *__pyx_v_stri...
function PyObject (line 1457) | static PyObject *__pyx_pw_15string_transfer_1str2int(PyObject *__pyx_sel...
function PyObject (line 1478) | static PyObject *__pyx_pf_15string_transfer_str2int(CYTHON_UNUSED PyObje...
function __pyx_f_15string_transfer_str2float (line 1510) | static double __pyx_f_15string_transfer_str2float(char *__pyx_v_string, ...
function PyObject (line 1541) | static PyObject *__pyx_pw_15string_transfer_3str2float(PyObject *__pyx_s...
function PyObject (line 1562) | static PyObject *__pyx_pf_15string_transfer_2str2float(CYTHON_UNUSED PyO...
function __pyx_f_15string_transfer_str2pct (line 1594) | static double __pyx_f_15string_transfer_str2pct(char *__pyx_v_string, CY...
function PyObject (line 1635) | static PyObject *__pyx_pw_15string_transfer_5str2pct(PyObject *__pyx_sel...
function PyObject (line 1656) | static PyObject *__pyx_pf_15string_transfer_4str2pct(CYTHON_UNUSED PyObj...
function __pyx_f_15string_transfer_str2bool (line 1688) | static int __pyx_f_15string_transfer_str2bool(char *__pyx_v_string, CYTH...
function PyObject (line 1945) | static PyObject *__pyx_pw_15string_transfer_7str2bool(PyObject *__pyx_se...
function PyObject (line 1966) | static PyObject *__pyx_pf_15string_transfer_6str2bool(CYTHON_UNUSED PyOb...
function PyObject (line 1998) | static PyObject *__pyx_f_15string_transfer_str2date(char *__pyx_v_string...
function PyObject (line 2213) | static PyObject *__pyx_pw_15string_transfer_9str2date(PyObject *__pyx_se...
function PyObject (line 2234) | static PyObject *__pyx_pf_15string_transfer_8str2date(CYTHON_UNUSED PyOb...
function PyObject (line 2266) | static PyObject *__pyx_f_15string_transfer_str2datetime(char *__pyx_v_st...
function PyObject (line 2691) | static PyObject *__pyx_pw_15string_transfer_11str2datetime(PyObject *__p...
function PyObject (line 2712) | static PyObject *__pyx_pf_15string_transfer_10str2datetime(CYTHON_UNUSED...
function PyObject (line 2744) | static PyObject *__pyx_f_15string_transfer_analyze_str_type(char *__pyx_...
function PyObject (line 3097) | static PyObject *__pyx_pw_15string_transfer_13analyze_str_type(PyObject ...
function PyObject (line 3118) | static PyObject *__pyx_pf_15string_transfer_12analyze_str_type(CYTHON_UN...
function CYTHON_UNUSED (line 3151) | static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(...
function __pyx_pf_7cpython_5array_5array___getbuffer__ (line 3162) | static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__...
function CYTHON_UNUSED (line 3395) | static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuff...
function __pyx_pf_7cpython_5array_5array_2__releasebuffer__ (line 3404) | static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UN...
function CYTHON_INLINE (line 3437) | static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobj...
function CYTHON_INLINE (line 3536) | static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobje...
function CYTHON_INLINE (line 3604) | static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobje...
function CYTHON_INLINE (line 3684) | static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__p...
function CYTHON_INLINE (line 3755) | static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__py...
type PyModuleDef (line 3800) | struct PyModuleDef
function CYTHON_SMALL_CODE (line 3888) | static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
function CYTHON_SMALL_CODE (line 3896) | static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
function CYTHON_SMALL_CODE (line 3939) | static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
function __Pyx_modinit_global_init_code (line 3954) | static int __Pyx_modinit_global_init_code(void) {
function __Pyx_modinit_variable_export_code (line 3964) | static int __Pyx_modinit_variable_export_code(void) {
function __Pyx_modinit_function_export_code (line 3972) | static int __Pyx_modinit_function_export_code(void) {
function __Pyx_modinit_type_init_code (line 3980) | static int __Pyx_modinit_type_init_code(void) {
function __Pyx_modinit_type_import_code (line 3988) | static int __Pyx_modinit_type_import_code(void) {
function __Pyx_modinit_variable_import_code (line 4017) | static int __Pyx_modinit_variable_import_code(void) {
function __Pyx_modinit_function_import_code (line 4025) | static int __Pyx_modinit_function_import_code(void) {
function __Pyx_PyMODINIT_FUNC (line 4054) | __Pyx_PyMODINIT_FUNC PyInit_string_transfer(void)
function CYTHON_SMALL_CODE (line 4059) | static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
function CYTHON_SMALL_CODE (line 4082) | static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, P...
function CYTHON_SMALL_CODE (line 4097) | static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CY...
function __Pyx_RefNannyAPIStruct (line 4546) | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modn...
function CYTHON_INLINE (line 4563) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, ...
function PyObject (line 4576) | static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
function CYTHON_INLINE (line 4591) | static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate,...
function CYTHON_INLINE (line 4603) | static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, P...
function __Pyx_WriteUnraisable (line 4614) | static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int cl...
function CYTHON_INLINE (line 4657) | static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *fun...
function PyObject (line 4680) | static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObjec...
function CYTHON_INLINE (line 4799) | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObj...
function CYTHON_INLINE (line 4819) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, ...
function PyObject (line 4839) | static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *ar...
function CYTHON_INLINE (line 4849) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function CYTHON_INLINE (line 4867) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function __Pyx_Raise (line 4879) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
function __Pyx_Raise (line 4930) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, P...
function CYTHON_INLINE (line 5038) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
function CYTHON_INLINE (line 5042) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject ...
function CYTHON_INLINE (line 5054) | static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj...
function CYTHON_INLINE (line 5066) | static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
function CYTHON_UNUSED (line 5098) | static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* functi...
function CYTHON_INLINE (line 5127) | static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expec...
function CYTHON_INLINE (line 5133) | static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t inde...
function CYTHON_INLINE (line 5140) | static CYTHON_INLINE int __Pyx_IterFinish(void) {
function __Pyx_IternextUnpackEndCheck (line 5175) | static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t exp...
function CYTHON_INLINE (line 5188) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
function PyTypeObject (line 5211) | static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *modu...
function PyObject (line 5270) | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int l...
function PyObject (line 5335) | static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
function __Pyx_CLineForTraceback (line 5350) | static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
function __pyx_bisect_code_objects (line 5391) | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries...
function PyCodeObject (line 5412) | static PyCodeObject *__pyx_find_code_object(int code_line) {
function __pyx_insert_code_object (line 5426) | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_o...
function PyCodeObject (line 5474) | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
function __Pyx_AddTraceback (line 5526) | static void __Pyx_AddTraceback(const char *funcname, int c_line,
function CYTHON_INLINE (line 5556) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LON...
function CYTHON_INLINE (line 5587) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
function __Pyx_InBases (line 6019) | static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
function CYTHON_INLINE (line 6027) | static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *...
function __Pyx_inner_PyErr_GivenExceptionMatches2 (line 6043) | static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObj...
function CYTHON_INLINE (line 6065) | static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObje...
function __Pyx_PyErr_GivenExceptionMatchesTuple (line 6073) | static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, Py...
function CYTHON_INLINE (line 6094) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err...
function CYTHON_INLINE (line 6106) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *er...
function __Pyx_check_binary_version (line 6118) | static int __Pyx_check_binary_version(void) {
function __Pyx_InitStrings (line 6134) | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
function CYTHON_INLINE (line 6166) | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_...
function CYTHON_INLINE (line 6169) | static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
function CYTHON_INLINE (line 6196) | static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObjec...
function CYTHON_INLINE (line 6238) | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
function CYTHON_INLINE (line 6243) | static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
function PyObject (line 6250) | static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* resul...
function CYTHON_INLINE (line 6319) | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
function CYTHON_INLINE (line 6381) | static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
function CYTHON_INLINE (line 6384) | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
Copy disabled (too large)
Download .json
Condensed preview — 122 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (15,308K chars).
[
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 834,
"preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Describe the b"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 595,
"preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Is your fea"
},
{
"path": "DaPy/__init__.py",
"chars": 2935,
"preview": "# user/bin/python\n#########################################\n# Author : Xuansheng Wu \n# Email "
},
{
"path": "DaPy/core/DataSet.py",
"chars": 33165,
"preview": "from collections import Counter, Iterator, namedtuple\nfrom copy import copy\nfrom functools import wraps\nfrom operator im"
},
{
"path": "DaPy/core/__init__.py",
"chars": 280,
"preview": "from .base import SeriesSet, Frame, Matrix, Series\nfrom .base import is_seq, is_iter, is_math, is_value, is_str, argsort"
},
{
"path": "DaPy/core/base/BaseSheet.py",
"chars": 59458,
"preview": "from collections import Counter, defaultdict\nfrom copy import copy\nfrom itertools import chain, combinations, repeat\nfro"
},
{
"path": "DaPy/core/base/DapyObject.py",
"chars": 971,
"preview": "from threading import Lock\nfrom functools import wraps\n\n\nclass Object(object):\n '''The base object for DaPy to gurant"
},
{
"path": "DaPy/core/base/IndexArray.py",
"chars": 8827,
"preview": "from collections import Sequence\nfrom itertools import chain\nfrom bisect import bisect_left, bisect_right\nfrom operator "
},
{
"path": "DaPy/core/base/LinkedArray.py",
"chars": 2241,
"preview": "from ctypes import Structure, POINTER, pointer, c_int as C_INT, byref\nfrom collections import Sequence, namedtuple\nclass"
},
{
"path": "DaPy/core/base/Matrix.py",
"chars": 25867,
"preview": "from array import array\nfrom collections import deque, namedtuple\nfrom copy import copy, deepcopy\nfrom csv import reader"
},
{
"path": "DaPy/core/base/Series.py",
"chars": 16841,
"preview": "from copy import copy\nfrom collections import Counter\nfrom itertools import repeat, compress, accumulate\nfrom datetime i"
},
{
"path": "DaPy/core/base/Sheet.py",
"chars": 79830,
"preview": "'''\nThis file is a part of DaPy project\n\nWe define three base data structures for operating \ndata like an excel. In cont"
},
{
"path": "DaPy/core/base/Views/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "DaPy/core/base/__init__.py",
"chars": 716,
"preview": "from .Sheet import SeriesSet, Frame\nfrom .Matrix import Matrix\nfrom .Series import Series\nfrom .utils import is_seq, is_"
},
{
"path": "DaPy/core/base/absents/Frame.py",
"chars": 11399,
"preview": "class Frame(BaseSheet):\n '''Maintains the data as records.\n '''\n\n def __init__(self, frame=None, columns=None, "
},
{
"path": "DaPy/core/base/constant.py",
"chars": 1569,
"preview": "from array import array\nfrom collections import Iterable, deque, namedtuple\nfrom datetime import datetime\nfrom sys impor"
},
{
"path": "DaPy/core/base/row.py",
"chars": 5709,
"preview": "from collections import Iterable, OrderedDict, Sequence\nfrom copy import copy\nfrom .constant import STR_TYPE, VALUE_TYPE"
},
{
"path": "DaPy/core/base/utils/__init__.py",
"chars": 5788,
"preview": "from math import isnan as _isnan\nfrom re import compile as _compile\nfrom operator import itemgetter\nfrom collections imp"
},
{
"path": "DaPy/core/base/utils/py_string_transfer.py",
"chars": 608,
"preview": "from distutils.util import strtobool\n\nstr2int = int\nstr2float = float\nstr2pct = lambda val: float(val.replace('%', '')) "
},
{
"path": "DaPy/core/base/utils/utils_2to3.py",
"chars": 607,
"preview": "from DaPy.core.base.constant import PYTHON3, PYTHON2\n\nif PYTHON2 is True:\n from itertools import izip, imap, ifilter,"
},
{
"path": "DaPy/core/base/utils/utils_grammar_parser.py",
"chars": 923,
"preview": "from DaPy.core.base.constant import PYTHON2, PYTHON3\n\nfrom distutils.util import strtobool\ntry:\n from dateutil.parser"
},
{
"path": "DaPy/core/base/utils/utils_isfunc.py",
"chars": 1850,
"preview": "from operator import itemgetter\nfrom collections import Iterable, OrderedDict\nfrom DaPy.core.base.constant import PYTHON"
},
{
"path": "DaPy/core/base/utils/utils_join_table.py",
"chars": 3500,
"preview": "from itertools import chain, repeat\nfrom operator import itemgetter\nfrom collections import deque\nfrom DaPy.core.base.co"
},
{
"path": "DaPy/core/base/utils/utils_regression.py",
"chars": 314,
"preview": "def simple_linear_reg(x, y):\n x_bar, y_bar = sum(x) / len(x), sum(y) / len(y)\n l_xx = sum(map(lambda x: (x - x_bar"
},
{
"path": "DaPy/core/base/utils/utils_str_patterns.py",
"chars": 673,
"preview": "from re import compile as re_compile\n\nPATTERN_AND_OR = re_compile(r'\\sand\\s|\\sor\\s')\nPATTERN_COMBINE = re_compile(r'[(]("
},
{
"path": "DaPy/core/base/utils/utils_str_transfer.py",
"chars": 937,
"preview": "from DaPy.core.base.constant import PYTHON2, PYTHON3\n\nfrom distutils.util import strtobool\ntry:\n from dateutil.parser"
},
{
"path": "DaPy/core/base/utils/utils_toolkits.py",
"chars": 132,
"preview": "from time import clock\nfrom datetime import datetime\n\n\nclass Timer(object):\n def __init__(self):\n self._begin "
},
{
"path": "DaPy/core/io.py",
"chars": 13208,
"preview": "from os.path import split\nfrom warnings import warn\nfrom datetime import datetime\nfrom itertools import repeat\n\nfrom .ba"
},
{
"path": "DaPy/core/sqlparser.py",
"chars": 3644,
"preview": "from re import compile as re_compile\nfrom re import findall\nfrom datetime import datetime\nfrom .base import SeriesSet, S"
},
{
"path": "DaPy/datasets/__init__.py",
"chars": 768,
"preview": "from DaPy import read\nfrom os.path import dirname, join\n\n__all__ = ['wine', 'iris', 'adult', 'example']\nmodule_path = di"
},
{
"path": "DaPy/datasets/adult/adult.csv",
"chars": 5733381,
"preview": "age,workplace,fnlwgt,education,education-num,marital-status,occupation,relationship,race,sex,capital-gain,capital-loss,h"
},
{
"path": "DaPy/datasets/adult/data.csv",
"chars": 5733381,
"preview": "age,workplace,fnlwgt,education,education-num,marital-status,occupation,relationship,race,sex,capital-gain,capital-loss,h"
},
{
"path": "DaPy/datasets/example/sample.csv",
"chars": 266,
"preview": "A_col,B_col,C_col,D_col\n2017/2/1,2,1.2,TRUE\n2017/2/2,,1.3,TRUE\n2017/2/3,3,1.4,TRUE\n2017/2/4,3,1.5,TRUE\n2017/2/5,5,1.6,FA"
},
{
"path": "DaPy/datasets/iris/data.csv",
"chars": 3716,
"preview": "sepal length,sepal width, petal length, petal width,class\n5.1,3.5,1.4,0.2,setosa\n4.9,3,1.4,0.2,setosa\n4.7,3.2,1.3,0.2,se"
},
{
"path": "DaPy/datasets/iris/info.txt",
"chars": 2675,
"preview": "Iris Plants Database\n====================\n\nNotes\n-----\nData Set Characteristics:\n :Number of Instances: 150 (50 in ea"
},
{
"path": "DaPy/datasets/lenses/data.txt",
"chars": 240,
"preview": "0\t0\t0\t0\t0\n0\t0\t0\t1\t1\n0\t0\t1\t0\t0\n0\t0\t1\t1\t2\n0\t1\t0\t0\t0\n0\t1\t0\t1\t1\n0\t1\t1\t0\t0\n0\t1\t1\t1\t2\n1\t0\t0\t0\t0\n1\t0\t0\t1\t1\n1\t0\t1\t0\t0\n1\t0\t1\t1\t2\n"
},
{
"path": "DaPy/datasets/wine/data.csv",
"chars": 34674,
"preview": "Alcohol,Malic acid,Ash,Alcalinity of ash,Magnesium,Total phenols,Flavanoids,Nonflavanoid phenols,Proanthocyanins,Color i"
},
{
"path": "DaPy/datasets/wine/info.txt",
"chars": 2427,
"preview": "Wine Data Database\n====================\n\nNotes\n-----\nData Set Characteristics:\n :Number of Instances: 178 (50 in each"
},
{
"path": "DaPy/doc/Quick Start.md",
"chars": 7076,
"preview": "## Quick Start\n#### Ⅰ. Loading a dataset\nDaPy comes with a few famous datasets, for examples the **iris** \nand **wine** "
},
{
"path": "DaPy/doc/Quick Start_Chinese.md",
"chars": 5337,
"preview": "## 快速开始\n#### Ⅰ. 加载数据集\nDaPy自带了少量著名的数据集,比如用于分类问题的**红酒分类**和**鸢尾花**数据集。\n接下来,我们首先启动一个Python Shell并加载作为例子的红酒数据集:\n```Python\n>>>"
},
{
"path": "DaPy/doc/README.md",
"chars": 5021,
"preview": "DaPy - don't limit your mind by syntax\n====\n  :\n '''dp.read('file.x"
},
{
"path": "DaPy/matlib.py",
"chars": 18808,
"preview": "from array import array\nfrom .core import Matrix, SeriesSet, Series\nfrom .core import nan, inf\nfrom .core import range, "
},
{
"path": "DaPy/methods/__init__.py",
"chars": 544,
"preview": "from .classifiers import MLPClassifier, DecisionTreeClassifier, LogistClassifier\nfrom .statistic import ANOVA, Discrimin"
},
{
"path": "DaPy/methods/classifiers/__init__.py",
"chars": 116,
"preview": "from .mlp import MLPClassifier\nfrom .tree import DecisionTreeClassifier\nfrom .linear_models import LogistClassifier\n"
},
{
"path": "DaPy/methods/classifiers/classifier.py",
"chars": 1922,
"preview": "from DaPy.core import Series, SeriesSet\nfrom DaPy.core import is_seq\nfrom copy import copy\n\n\ndef proba2label(seq, labels"
},
{
"path": "DaPy/methods/classifiers/linear_models.py",
"chars": 989,
"preview": "from DaPy.methods.core import BaseLinearModel\nfrom .classifier import BaseClassifier\nfrom DaPy.core.base import Series\n\n"
},
{
"path": "DaPy/methods/classifiers/mlp.py",
"chars": 2110,
"preview": "from copy import copy\n\nfrom DaPy.core import Matrix, Series, SeriesSet\nfrom DaPy.methods.core import BaseMLP\nfrom DaPy.o"
},
{
"path": "DaPy/methods/classifiers/tree.py",
"chars": 7963,
"preview": "from collections import Counter\nfrom math import log\nfrom DaPy import SeriesSet, Series\nfrom copy import copy, deepcopy\n"
},
{
"path": "DaPy/methods/core/__init__.py",
"chars": 243,
"preview": "from .base import Activators\nfrom .base import BaseEngineModel\nfrom .base import Dense, Input\n\nfrom .multilayer_perceptr"
},
{
"path": "DaPy/methods/core/base/__init__.py",
"chars": 167,
"preview": "from .layers import Dense, Input, Output\nfrom .activators import Activators, check_activations\nfrom .models import BaseE"
},
{
"path": "DaPy/methods/core/base/activators.py",
"chars": 2200,
"preview": "from warnings import filterwarnings\nfrom .models import BaseEngineModel\nfrom .utils import eng2str, str2eng\nfilterwarnin"
},
{
"path": "DaPy/methods/core/base/layers.py",
"chars": 3624,
"preview": "from math import sqrt\nfrom random import gauss, randint, uniform\n\nfrom DaPy.core.base import Matrix\n\nfrom .models import"
},
{
"path": "DaPy/methods/core/base/models.py",
"chars": 2594,
"preview": "\nfrom itertools import repeat\nfrom DaPy.core.base import is_str\nfrom .utils import str2eng, eng2str\n\nclass BaseEngineMod"
},
{
"path": "DaPy/methods/core/base/utils.py",
"chars": 483,
"preview": "from DaPy.core import LogWarn\n\ndef eng2str(obj):\n return str(obj).split()[1][1: -1]\n\ndef str2eng(obj):\n if str(obj"
},
{
"path": "DaPy/methods/core/bp_model.py",
"chars": 4219,
"preview": "from time import clock\n\nfrom DaPy.core import LogInfo, Series\nfrom .base import BaseEngineModel, Activators\n\nclass BaseB"
},
{
"path": "DaPy/methods/core/linear_model.py",
"chars": 2282,
"preview": "from itertools import repeat\nfrom math import sqrt\nfrom random import randint, random\nfrom time import clock, localtime\n"
},
{
"path": "DaPy/methods/core/multilayer_perceptron.py",
"chars": 9517,
"preview": "from itertools import repeat\nfrom math import sqrt\nfrom random import randint\nfrom time import clock, localtime\n\nfrom Da"
},
{
"path": "DaPy/methods/core/pagerank.py",
"chars": 2175,
"preview": "from time import clock\n\nfrom DaPy.core import LogInfo, Series\n\nfrom .base import BaseEngineModel\n\nclass PageRank(BaseEng"
},
{
"path": "DaPy/methods/core/tfidf.py",
"chars": 3880,
"preview": "from collections import Counter, defaultdict\nfrom heapq import nlargest\nfrom itertools import chain\nfrom math import log"
},
{
"path": "DaPy/methods/evaluator.py",
"chars": 4396,
"preview": "from DaPy.core import Matrix, SeriesSet, Series\nfrom DaPy.core import LogInfo, LogWarn, LogErr, is_seq\nfrom DaPy.matlib"
},
{
"path": "DaPy/methods/regressors/__init__.py",
"chars": 32,
"preview": "from .lr import LinearRegressor\n"
},
{
"path": "DaPy/methods/regressors/lr.py",
"chars": 604,
"preview": "from DaPy.methods.core import BaseLinearModel\n\nclass LinearRegressor(BaseLinearModel):\n def __init__(self, engine='nu"
},
{
"path": "DaPy/methods/statistic/__init__.py",
"chars": 339,
"preview": "from .compare_scaler import ANOVA, MoodTest\nfrom .discriminant_analysis import DiscriminantAnalysis\nfrom .compare_positi"
},
{
"path": "DaPy/methods/statistic/compare_position.py",
"chars": 9388,
"preview": "from collections import namedtuple, Counter\nfrom DaPy.core import is_math, is_seq, SeriesSet, DataSet, Series\nfrom DaPy."
},
{
"path": "DaPy/methods/statistic/compare_scaler.py",
"chars": 2797,
"preview": "from collections import namedtuple\nfrom DaPy.core import is_math, is_seq, is_str\nfrom DaPy.core import SeriesSet\nfrom Da"
},
{
"path": "DaPy/methods/statistic/discriminant_analysis.py",
"chars": 5967,
"preview": "from DaPy.core import DataSet, Matrix as mat, SeriesSet\nfrom DaPy.matlib import cov, mean\nfrom DaPy.operation import col"
},
{
"path": "DaPy/methods/statistic/distribution.py",
"chars": 396,
"preview": "from DaPy.core.base import LogWarn\n\ndef unsupportedTest(*args, **kwrds):\n return '-'\n\ntry:\n from scipy.stats impor"
},
{
"path": "DaPy/methods/statistic/kMeans.py",
"chars": 2595,
"preview": "# user/bin/python\n#########################################\n# Author : Feichi Yang\n# Edited by : Xuansheng "
},
{
"path": "DaPy/methods/utils.py",
"chars": 1501,
"preview": "from DaPy.core import SeriesSet, is_iter, Series\nfrom DaPy.matlib import describe\nfrom collections import namedtuple\nfro"
},
{
"path": "DaPy/operation.py",
"chars": 11694,
"preview": "from bisect import bisect_right, bisect_left\nfrom copy import copy\nfrom collections import Counter\nfrom operator import"
},
{
"path": "DaPy/tests/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "DaPy/tests/scripts/performance.py",
"chars": 3218,
"preview": "# user/bin/python2\n#########################################\n# Author : Xuansheng Wu \n# Email "
},
{
"path": "DaPy/tests/scripts/test_lr.py",
"chars": 196,
"preview": "import DaPy as dp\nfrom DaPy.methods import LinearRegression as dp_lr\n\ndata = dp.read('advertising.csv')\nlr_dp = dp_lr('n"
},
{
"path": "DaPy/tests/scripts/test_matrix.py",
"chars": 1273,
"preview": "import numpy as np\nimport DaPy as dp\nfrom timeit import Timer\n\nX = [[17, 2, 9, 2],\n [21, 8, 1, 46],\n [4, 3, 2, 1"
},
{
"path": "DaPy/tests/scripts/test_merge.py",
"chars": 1160,
"preview": "import DaPy as dp\n\nfor key in (True, False, 'other', 'self'):\n for same in (True, False):\n left = dp.SeriesSet"
},
{
"path": "DaPy/tests/scripts/test_methods.py",
"chars": 653,
"preview": "from DaPy import datasets\nfrom DaPy.methods import MLP, LDA\n\niris, info = datasets.iris()\niris.normalized()\niris.shuffle"
},
{
"path": "DaPy/tests/test_CoreBaseIndexArray.py",
"chars": 1996,
"preview": "from unittest import TestCase\nfrom collections import OrderedDict\nfrom datetime import datetime\nfrom DaPy.core.base.Inde"
},
{
"path": "DaPy/tests/test_CoreBaseSeries.py",
"chars": 1996,
"preview": "from unittest import TestCase\nfrom collections import OrderedDict\nfrom datetime import datetime\nfrom DaPy.core.base.Inde"
},
{
"path": "DaPy/tests/test_CoreBaseSheet.py",
"chars": 15087,
"preview": "from unittest import TestCase\nfrom collections import OrderedDict\nfrom DaPy import SeriesSet, nan, Series\nfrom copy impo"
},
{
"path": "DaPy/tests/test_CoreBaseTools.py",
"chars": 2323,
"preview": "from unittest import TestCase\nfrom collections import OrderedDict\nfrom datetime import datetime\nfrom DaPy.core.base.util"
},
{
"path": "DaPy/tests/test_methods.py",
"chars": 1726,
"preview": "from unittest import TestCase\n\nfrom DaPy import datasets, io, Series, exp\nfrom DaPy.methods.classifiers import MLPClassi"
},
{
"path": "README.md",
"chars": 7654,
"preview": "<img src=\"https://github.com/JacksonWuxs/DaPy/blob/master/doc/material/DaPy.png\">\n<i>This open source framework fluently"
},
{
"path": "README_Chinese.md",
"chars": 9543,
"preview": "<img src=\"https://github.com/JacksonWuxs/DaPy/blob/master/doc/material/DaPy.png\">\n<i>本开源项目流利地实现你在数据挖掘中的想法</i>\n\n# DaPy - "
},
{
"path": "_config.yml",
"chars": 27,
"preview": "theme: jekyll-theme-minimal"
},
{
"path": "clib/io.c",
"chars": 284631,
"preview": "/* Generated by Cython 0.29.6 */\n\n#define PY_SSIZE_T_CLEAN\n#include \"Python.h\"\n#ifndef Py_PYTHON_H\n #error Python hea"
},
{
"path": "clib/io.html",
"chars": 136643,
"preview": "<!DOCTYPE html>\n<!-- Generated by Cython 0.29.6 -->\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html"
},
{
"path": "clib/io.pyx",
"chars": 4414,
"preview": "# -*- coding: utf-8 -*-\n\"\"\"\ndata_mining.pyx\n~~~~~~~~~~~~~~~\nThis module is a cython pyx file that is used to mine text e"
},
{
"path": "clib/math.c",
"chars": 914397,
"preview": "/* Generated by Cython 0.29.6 */\n\n#define PY_SSIZE_T_CLEAN\n#include \"Python.h\"\n#ifndef Py_PYTHON_H\n #error Python hea"
},
{
"path": "clib/math.html",
"chars": 119001,
"preview": "<!DOCTYPE html>\n<!-- Generated by Cython 0.29.6 -->\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html"
},
{
"path": "clib/math.pyx",
"chars": 2186,
"preview": "import cython\nfrom cpython.array cimport array\nfrom itertools import chain, repeat\nfrom libc.stdlib cimport malloc\n\ncdef"
},
{
"path": "clib/setup.py",
"chars": 150,
"preview": "from distutils.core import setup, Extension\nfrom Cython.Build import cythonize\n\nsetup(ext_modules=cythonize('string_tran"
},
{
"path": "clib/string_transfer.c",
"chars": 253118,
"preview": "/* Generated by Cython 0.29.6 */\n\n#define PY_SSIZE_T_CLEAN\n#include \"Python.h\"\n#ifndef Py_PYTHON_H\n #error Python hea"
},
{
"path": "clib/string_transfer.html",
"chars": 146598,
"preview": "<!DOCTYPE html>\n<!-- Generated by Cython 0.29.6 -->\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html"
},
{
"path": "clib/string_transfer.pyx",
"chars": 2688,
"preview": "from cython import boundscheck, wraparound\nfrom libc.stdlib cimport atoll, atof\nfrom datetime import datetime, date\nfrom"
},
{
"path": "doc/Guide Book/Chinese/README.md",
"chars": 2341,
"preview": "# DaPy - 享受数据挖掘之旅\n[简介](https://github.com/JacksonWuxs/DaPy/blob/master/Guide%20Book/README.md#introduction) \n - [什么是"
},
{
"path": "doc/Guide Book/Chinese/快速开始.md",
"chars": 5316,
"preview": "## 快速开始\n#### Ⅰ. 加载数据集\nDaPy自带了少量著名的数据集,比如用于分类问题的**红酒分类**和**鸢尾花**数据集。\n接下来,我们首先启动一个Python Shell并加载作为例子的红酒数据集:\n```Python\n>>>"
},
{
"path": "doc/Guide Book/English/Features.md",
"chars": 7999,
"preview": "## Features\n**Convinience** and **efficiency** are the cornerstone of DaPy. \nSince the very beginning, we have designed "
},
{
"path": "doc/Guide Book/English/Introduction.md",
"chars": 3724,
"preview": "## Introduction\n#### What is DaPy?\nDaPy is a Python package providing efficiency and readily usable data structures desi"
},
{
"path": "doc/Guide Book/English/Performance Test for DaPy.md",
"chars": 2967,
"preview": "### Performance Test for DaPy\n\n#### Date: 2019-10-19\n\n#### Version: 1.10.1\n\n#### Data\n\n* Information\n\n We use the data "
},
{
"path": "doc/Guide Book/English/Quick Start.md",
"chars": 7248,
"preview": "## Quick Start\n#### Ⅰ. Loading a dataset\nDaPy comes with a few famous datasets, for examples the **iris** \nand **wine** "
},
{
"path": "doc/Guide Book/README.md",
"chars": 1818,
"preview": "# DaPy - Enjoy the Tour in Data Mining \n[Introduction](https://github.com/JacksonWuxs/DaPy/blob/master/Guide%20Book/Engl"
},
{
"path": "doc/Quick Start/Chinese.md",
"chars": 5170,
"preview": "## 快速开始\n#### Ⅰ. 加载数据集\nDaPy自带了少量著名的数据集,比如用于分类问题的**红酒分类**和**鸢尾花**数据集。\n接下来,我们首先启动一个Python Shell并加载作为例子的红酒数据集:\n```Python\n>>>"
},
{
"path": "doc/Quick Start/English.md",
"chars": 7058,
"preview": "## Quick Start\n#### Ⅰ. Loading a dataset\nDaPy comes with a few famous datasets, for examples the **iris** \nand **wine** "
},
{
"path": "doc/Quick Start/get-start.py",
"chars": 448,
"preview": "from DaPy import datasets\nfrom DaPy.methods.classifiers import MLPClassifier\nfrom DaPy.methods.evaluator import Performa"
},
{
"path": "doc/Reading/DaPy - Introduction.txt",
"chars": 0,
"preview": ""
},
{
"path": "doc/Reading/DaPy - Smooth Data Mining Experience.md",
"chars": 12935,
"preview": "### DaPy - Provides You With Smooth Data Processing Experience You've Never Had\nAre you upset by the strict data struct"
},
{
"path": "doc/Reading/DaPy - 丝滑般实现数据分析.md",
"chars": 10237,
"preview": "### DaPy - 带你领略从未有过的丝滑般体验\n总因为Pandas严格的数据结构要求让你感受到很苦恼?为了实现一个简单的操作也要查阅很多的文档而头疼?\n\nDaPy来解放你啦!你可以用[DaPy](https://github.com/J"
},
{
"path": "doc/Reading/DaPy - 简介.md",
"chars": 13800,
"preview": "# 比Pandas好用的数据分析框架:DaPy\n\n  2018 - 2019 Xuansheng Wu\n\nThis program is free software: you can redistribute it and/or modif"
},
{
"path": "doc/homepage/TODO.md",
"chars": 1939,
"preview": "### TODO \n\n:heavy_check_mark: = Done :running: = In Development :calendar: = Put On the Agenda :thi"
},
{
"path": "doc/homepage/Version-Log.md",
"chars": 6476,
"preview": "#### Version-Log\n\n- V1.11.1 (2019-11-12)\n - Refactored the structure of DaPy, `SeriesSet` and `Series` are thread-safet"
},
{
"path": "doc/info.txt",
"chars": 413,
"preview": "\nHope you enjoy your new logo, here are the people that\nmade your beautiful logo happen :)\nfont name: Aleo-Regular\nfont "
},
{
"path": "doc/material/DaPy.ai",
"chars": 606285,
"preview": "%PDF-1.5\r%\r\n1 0 obj\r<</Metadata 2 0 R/OCProperties<</D<</ON[7 0 R 46 0 R 84 0 R 123 0 R 162 0 R 201 0 R 240 0 R 277 0 R]"
},
{
"path": "setup.py",
"chars": 1278,
"preview": "from setuptools import setup, find_packages\nfrom DaPy import __version__, _unittests\nfrom DaPy.core.base.constant import"
}
]
// ... and 6 more files (download for full content)
About this extraction
This page contains the full source code of the JacksonWuxs/DaPy GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 122 files (13.9 MB), approximately 3.6M tokens, and a symbol index with 1704 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.