@@ -193,6 +193,54 @@ IP or hostname.
193193 :members:
194194 :inherited- members:
195195
196+
197+ Pandas Integration
198+ ------------------
199+
200+ The `analyzer` module contains an optional integration with the Pandas_ Python
201+ library. `pandas` is a robust data analytics toolset that integrates especially
202+ well with Jupyter Notebooks. Even if you don' t plan to use the more sophisticated
203+ features `pandas` offers, the vastly improved display of `analyzer` results in
204+ notebooks is well worth enabling the integration.
205+
206+ To get started, install the `pandas` Python package, ideally in a
207+ `virtual environment < https:// docs.python.org/ 3 / library/ venv.html> ` _:
208+
209+ `` pip install pandas``
210+
211+ Nearly all `analyzer` objects offer results formatted as a Pandas `DataFrame` ,
212+ which is the standard two- dimensional (tabluar) data format in Pandas. You can access
213+ the data with the `as_df` property or by calling the `to_dataframe()` method on an
214+ analyzer object . For example:
215+
216+ `` analyzer.Hostname(' riskiq.net' ).summary.as_df``
217+
218+ If this is the last line of a cell in a Jupyter notebook, and you run that
219+ cell, you' ll get a one-line tabular output with the summary data in columns.
220+
221+ To view a list of pDNS records:
222+
223+ `` analyzer.Hostname(' riskiq.net' ).resolutions.as_df``
224+
225+ Internally, the `as_df` property calls `to_dataframe()` on each object with
226+ no parameters, which results in a default rendering of the dataframe. Some objects,
227+ like :class :`passivetotal.analyzer.illuminate.ReputationScore` , offer additional options
228+ in their implementation of `to_dataframe()` . For example:
229+ `` analyzer.Hostname(' jquery.su' ).reputation.to_dataframe(explode_rules = True )``
230+
231+ This will show the reputation score with one row for each rule returned by the
232+ Reputation API . It uses the pandas `DataFrame.explode` method to unstack a list into
233+ a set of rows and columns, hence the parameter name `explode_rules` .
234+
235+ Pandas dataframes are easily exported as CSV and offer capabilities to perform
236+ SQL - style joins and Excel- style VLOOKUPs. Consult the docs to learn what' s possible.
237+
238+
239+ .. _Pandas: https:// pandas.pydata.org/ docs/ index.html
240+
241+
242+
243+
196244Using Record Lists
197245------------------
198246Several attributes of Hostnames and IPs return lists of records from the API . The
0 commit comments