aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-10-04 08:18:49 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-10-04 08:18:49 +0200
commit284ac6c00ae53baa435d589b69751f5f292df3b1 (patch)
tree535ae4afd84820c3e8d26cf039287e37a49ca9b4 /src
parentb735e67fef864b675d86a33eb8409d379bd62307 (diff)
downloadee-python-284ac6c00ae53baa435d589b69751f5f292df3b1.tar.gz
ee-python-284ac6c00ae53baa435d589b69751f5f292df3b1.tar.bz2
ee-python-284ac6c00ae53baa435d589b69751f5f292df3b1.tar.xz
ee-python-284ac6c00ae53baa435d589b69751f5f292df3b1.zip
o Adding DigikeyRepository.to_pandas().
Diffstat (limited to 'src')
-rw-r--r--src/ee/digikey/__init__.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ee/digikey/__init__.py b/src/ee/digikey/__init__.py
index 957aa40..d1664e2 100644
--- a/src/ee/digikey/__init__.py
+++ b/src/ee/digikey/__init__.py
@@ -115,6 +115,16 @@ class DigikeyProduct(object):
attributes[key] = value
return c
+ def _to_pandas_dict(self):
+ value = {
+ "MPN": self.mpn,
+ "Digi-Key": self.part_number,
+ "URL": self.url,
+ }
+ for a in self.attributes:
+ value[a.attribute_type.label] = a.value
+ return value
+
from_ini_r = re.compile("([^/]*)/(.*)")
@staticmethod
@@ -362,3 +372,10 @@ class DigikeyRepository(object):
for p in self.products:
if p.mpn == mpn:
return p
+
+ def to_pandas(self):
+ import pandas
+
+ data = [part._to_pandas_dict() for part in self.products]
+ index = [part.mpn for part in self.products]
+ return pandas.DataFrame(data=data, index=index)