-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDataFrameRow.py
executable file
·90 lines (73 loc) · 2.37 KB
/
DataFrameRow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#=========================================================================
# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
# License (GPL) version 3, as described at www.opensource.org.
# 2018 William H. Majoros ([email protected])
#=========================================================================
from __future__ import (absolute_import, division, print_function,
unicode_literals, generators, nested_scopes, with_statement)
from builtins import (bytes, dict, int, list, object, range, str, ascii,
chr, hex, input, next, oct, open, pow, round, super, filter, map, zip)
import sys
#=========================================================================
# Attributes:
# label : string
# values : array of values
# Methods:
# row=DataFrameRow()
# elem=row[i] # first element is at 0 (the label is not counted)
# label=row.getLabel()
# raw=raw.getRaw()
# row.rename(label)
# n=row.length()
# row.toInt()
# row.toFloat()
# row.append(value)
# row.print(handle)
# newRow=row.clone()
# row.log()
# row.log2()
# row.log10()
#=========================================================================
class DataFrameRow:
def __init__(self):
self.label=""
self.values=[]
def log(self):
values=self.values
for i in range(len(values)):
values[i]=log(values[i])
def log2(self):
values=self.values
for i in range(len(values)):
values[i]=log2(values[i])
def log10(self):
values=self.values
for i in range(len(values)):
values[i]=log10(values[i])
def getRaw(self):
return self.values
def clone(self):
r=DataFrameRow()
r.label=self.label
for x in self.values:
r.values.append(x)
return r
def __getitem__(self,i):
return self.values[i]
def __setitem__(self,i,value):
self.values[i]=value
def print(self,handle):
if(self.label!=""): print(self.label+"\t",end="",file=handle)
print("\t".join([str(x) for x in self.values]),sep="",file=handle)
def append(self,value):
self.values.append(value)
def length(self):
return len(self.values)
def getLabel(self):
return self.label
def rename(self,x):
self.label=x
def toInt(self):
self.values=[int(x) for x in self.values]
def toFloat(self):
self.values=[float(x) for x in self.values]