Skip to content

Commit c6b236d

Browse files
committed
first commit with cleaned up code
git-svn-id: http://pandas.googlecode.com/svn/trunk@5 d5231056-7de3-11de-ac95-d976489f1ece
1 parent 445114e commit c6b236d

36 files changed

+21658
-0
lines changed

LICENSE

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2008-2009 AQR Capital Management, LLC
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of any
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include TODO LICENSE README
2+
include setup.py setupegg.py
3+
include examples/data/*
4+
recursive-include examples *

README

Whitespace-only changes.

TODO

Whitespace-only changes.

pandas/__init__.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Pandas - a library for panel, time series, or cross-sectional data analysis
3+
===========================================================================
4+
5+
Main data structures (see docstrings for detailed documentation)
6+
--------------------
7+
Index
8+
Represent row or column labels in Series / DataFrame structures
9+
10+
Series / TimeSeries
11+
Represents standard 1-dimensional cross-section (resp. time series)
12+
As an numpy.ndarray subclass, compatible with ufuncs and other NumPy
13+
functions
14+
15+
DataFrame / DataMatrix
16+
Represent collections of Series objects, enable easy management
17+
of multiple time series / cross-sections
18+
19+
DateRange
20+
Index subclass for generating arrays of fixed frequency dates
21+
22+
Subpackages
23+
-----------
24+
core
25+
Implementations of core data structures, basic building blocks. Most of
26+
the user-relevant code is accessible through the top-level namespace
27+
io
28+
Persistence, parsing, and data loading tools
29+
lib
30+
C, Cython, and Fortran extensions for other components
31+
stats
32+
Standard
33+
"""
34+
35+
from pandas.core.api import *
36+
from pandas.io.parsers import parseCSV, parseText, parseExcel

pandas/core/__init__.py

Whitespace-only changes.

pandas/core/api.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import numpy as np
2+
3+
from pandas.core.daterange import DateRange
4+
from pandas.core.datetools import DateOffset
5+
from pandas.core.frame import DataFrame
6+
from pandas.core.index import Index
7+
from pandas.core.matrix import DataMatrix
8+
from pandas.core.series import Series, TimeSeries
9+
10+
import pandas.core.datetools as datetools
11+
12+
from pandas.lib.tseries import isnull, notnull

pandas/core/collection.py

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
from __future__ import with_statement
2+
3+
from collections import defaultdict
4+
from pandas.core.mixins import Picklable
5+
from pandas.core.index import Index
6+
from pandas.core.pytools import rands, adjoin, groupby
7+
import cPickle
8+
import os
9+
10+
__all__ = ['PickleContainer']
11+
12+
class PickleContainer(Picklable):
13+
"""
14+
Store collection of objects on disk with this dict-like object.
15+
16+
Parameters
17+
----------
18+
dirPath: string
19+
Directory where to store the objects
20+
lruSize: int
21+
Number of objects to keep in memory (not implemented yet)
22+
"""
23+
def __init__(self, dirPath, lruSize=5):
24+
self.dirPath = dirPath
25+
if not os.path.exists(dirPath):
26+
os.mkdir(dirPath)
27+
28+
self._lruSize = lruSize
29+
30+
self._paths = {}
31+
self._classes = {}
32+
self._lru = {}
33+
34+
def __repr__(self):
35+
output = str(self.__class__) + '\n'
36+
keys, values = zip(*self._classes.iteritems())
37+
output += adjoin(5, map(str, keys), map(str, values))
38+
return output
39+
40+
def __setitem__(self, key, value):
41+
theKey = rands(10)
42+
filePath = self.dirPath + '/' + theKey
43+
44+
self._paths[key] = filePath
45+
46+
if isinstance(value, Picklable):
47+
value.save(filePath)
48+
else:
49+
with open(filePath, 'w') as f:
50+
cPickle.dump(value, f)
51+
52+
self._paths[key] = filePath
53+
self._classes[key] = value.__class__
54+
55+
def __getitem__(self, key):
56+
if key not in self._paths:
57+
raise Exception('Requested key not in this container!')
58+
59+
thePath = self._paths[key]
60+
theClass = self._classes[key]
61+
62+
if issubclass(theClass, Picklable):
63+
obj = theClass.load(thePath)
64+
else:
65+
with open(thePath, 'rb') as f:
66+
obj = cPickle.load(f)
67+
68+
return obj
69+
70+
def __delitem__(self, key):
71+
del self._paths[key]
72+
del self._classes[key]
73+
74+
def __iter__(self):
75+
return iter(self._paths)
76+
77+
def iteritems(self):
78+
for key, path in self._paths.iteritems():
79+
yield key, self[key]
80+
81+
def keys(self):
82+
return self._paths.keys()
83+
84+
def values(self):
85+
result = []
86+
for key in self._paths:
87+
result.append(self[key])
88+
return result

0 commit comments

Comments
 (0)