Skip to content

Commit

Permalink
Merge pull request #179 from pandas-profiling/develop
Browse files Browse the repository at this point in the history
Support for offline mode. Adds feature requested in [#177].
  • Loading branch information
sbrugman authored Jun 20, 2019
2 parents 58c16a1 + 0ce8153 commit b713c19
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 65 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ profile.to_file(output_file="output.html")

## Dependencies

* **An internet connection.** Pandas-profiling requires an internet connection to download the Bootstrap and JQuery libraries. I might change this in the future, let me know if you want that sooner than later.
* python ([>= 3.5](https://python3statement.org/))
* pandas (>=0.19)
* matplotlib (>=1.4)
Expand Down
6 changes: 5 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ <h3 id="advanced-usage">Advanced usage</h3>
</code></pre>
<h2 id="dependencies">Dependencies</h2>
<ul>
<li><strong>An internet connection.</strong> Pandas-profiling requires an internet connection to download the Bootstrap and JQuery libraries. I might change this in the future, let me know if you want that sooner than later.</li>
<li>python (<a href="https://python3statement.org/">&gt;= 3.5</a>)</li>
<li>pandas (&gt;=0.19)</li>
<li>matplotlib
Expand Down Expand Up @@ -202,6 +201,7 @@ <h2 id="dependencies">Dependencies</h2>
# Render HTML
self.html = to_html(sample, description_set)
self.minify_html = config[&#34;minify_html&#34;].get(bool)
self.use_local_assets = config[&#34;use_local_assets&#34;].get(bool)
self.title = config[&#34;title&#34;].get(str)
self.description_set = description_set
self.sample = sample
Expand Down Expand Up @@ -268,6 +268,7 @@ <h2 id="dependencies">Dependencies</h2>
missing=len(self.description_set[&#34;missing&#34;]) &gt; 0,
sample=len(self.sample) &gt; 0,
version=__version__,
offline=self.use_local_assets,
)

def get_unique_file_name(self):
Expand Down Expand Up @@ -396,6 +397,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
# Render HTML
self.html = to_html(sample, description_set)
self.minify_html = config[&#34;minify_html&#34;].get(bool)
self.use_local_assets = config[&#34;use_local_assets&#34;].get(bool)
self.title = config[&#34;title&#34;].get(str)
self.description_set = description_set
self.sample = sample
Expand Down Expand Up @@ -462,6 +464,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
missing=len(self.description_set[&#34;missing&#34;]) &gt; 0,
sample=len(self.sample) &gt; 0,
version=__version__,
offline=self.use_local_assets,
)

def get_unique_file_name(self):
Expand Down Expand Up @@ -634,6 +637,7 @@ <h2 id="returns">Returns</h2>
missing=len(self.description_set[&#34;missing&#34;]) &gt; 0,
sample=len(self.sample) &gt; 0,
version=__version__,
offline=self.use_local_assets,
)</code></pre>
</details>
</dd>
Expand Down
77 changes: 49 additions & 28 deletions examples/titanic/titanic_report.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pandas_profiling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, df, **kwargs):
# Render HTML
self.html = to_html(sample, description_set)
self.minify_html = config["minify_html"].get(bool)
self.use_local_assets = config["use_local_assets"].get(bool)
self.title = config["title"].get(str)
self.description_set = description_set
self.sample = sample
Expand Down Expand Up @@ -137,6 +138,7 @@ def to_html(self) -> str:
missing=len(self.description_set["missing"]) > 0,
sample=len(self.sample) > 0,
version=__version__,
offline=self.use_local_assets,
)

def get_unique_file_name(self):
Expand Down
3 changes: 3 additions & 0 deletions pandas_profiling/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ pool_size: 0
# Minify the html
minify_html: True

# Offline support
use_local_assets: True

# Per variable type description settings
vars:
num:
Expand Down

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pandas_profiling/view/templates/assets/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pandas_profiling/view/templates/assets/bootstrap.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pandas_profiling/view/templates/assets/jquery-latest.min.js

Large diffs are not rendered by default.

File renamed without changes.
34 changes: 34 additions & 0 deletions pandas_profiling/view/templates/javascript.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% if offline %}
<script>
{% include 'assets/jquery-latest.min.js' %}
{% include 'assets/bootstrap.min.js' %}
</script>
{% else %}
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
{% endif %}
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})

$("a[href^='#'].anchor").on('click', function (e) {

// prevent default anchor click behavior
e.preventDefault();

// store hash
var hash = this.hash;

// animate
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 300, function () {

// when done, add hash to url
// (default click behaviour)
window.location.hash = hash;
});

});
</script>
15 changes: 15 additions & 0 deletions pandas_profiling/view/templates/style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% if offline %}
<style>
{% include 'assets/bootstrap.min.css' %}
{% include 'assets/bootstrap-theme.min.css' %}
</style>
{% else %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
{% endif %}
<style>
body {
padding-top: 80px;
}
{% include 'assets/style.css' %}
</style>
37 changes: 2 additions & 35 deletions pandas_profiling/view/templates/wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,13 @@

<title>{{ title }}</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<style>
body {
padding-top: 80px;
}
{% include 'style.css' %}
</style>
{% include 'style.html' %}
</head>

<body>
{% include 'navigation.html' %}
{{ content }}
{% include 'footer.html' %}
<script src="https://code.jquery.com/jquery-latest.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})

$("a[href^='#'].anchor").on('click', function (e) {

// prevent default anchor click behavior
e.preventDefault();

// store hash
var hash = this.hash;

// animate
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 300, function () {

// when done, add hash to url
// (default click behaviour)
window.location.hash = hash;
});

});
</script>
{% include 'javascript.html' %}
</body>
</html>

0 comments on commit b713c19

Please sign in to comment.