/usr/share/doc/python-dask-doc/html/dataframe-overview.html is in python-dask-doc 0.16.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Overview — dask 0.16.0 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/style.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="dask 0.16.0 documentation" href="index.html"/>
<link rel="up" title="DataFrame" href="dataframe.html"/>
<link rel="next" title="Create and Store Dask DataFrames" href="dataframe-create.html"/>
<link rel="prev" title="DataFrame" href="dataframe.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> dask
</a>
<div class="version">
0.16.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="install.html">Install Dask</a></li>
<li class="toctree-l1"><a class="reference internal" href="use-cases.html">Use Cases</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples-tutorials.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="cheatsheet.html">Dask Cheat Sheet</a></li>
</ul>
<p class="caption"><span class="caption-text">Collections</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="array.html">Array</a></li>
<li class="toctree-l1"><a class="reference internal" href="bag.html">Bag</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="dataframe.html">DataFrame</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Overview</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#design">Design</a></li>
<li class="toctree-l3"><a class="reference internal" href="#common-uses-and-anti-uses">Common Uses and Anti-Uses</a></li>
<li class="toctree-l3"><a class="reference internal" href="#dask-dataframe-copies-the-pandas-api">Dask.dataframe copies the pandas API</a></li>
<li class="toctree-l3"><a class="reference internal" href="#scope">Scope</a></li>
<li class="toctree-l3"><a class="reference internal" href="#execution">Execution</a></li>
<li class="toctree-l3"><a class="reference internal" href="#limitations">Limitations</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="dataframe-create.html">Create and Store Dask DataFrames</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataframe-api.html">API</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataframe-performance.html">Dask DataFrame Performance Tips</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataframe-design.html">Internal Design</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataframe-groupby.html">Shuffling for GroupBy and Join</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataframe-groupby.html#aggregate">Aggregate</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="delayed.html">Delayed</a></li>
<li class="toctree-l1"><a class="reference internal" href="futures.html">Futures</a></li>
<li class="toctree-l1"><a class="reference internal" href="machine-learning.html">Machine Learning</a></li>
</ul>
<p class="caption"><span class="caption-text">Scheduling</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="distributed.html">Distributed Scheduling</a></li>
<li class="toctree-l1"><a class="reference internal" href="scheduler-overview.html">Scheduler Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="scheduler-choice.html">Choosing between Schedulers</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.html">Shared Memory</a></li>
<li class="toctree-l1"><a class="reference internal" href="scheduling-policy.html">Scheduling in Depth</a></li>
</ul>
<p class="caption"><span class="caption-text">Diagnostics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="inspect.html">Inspecting Dask objects</a></li>
<li class="toctree-l1"><a class="reference internal" href="diagnostics.html">Diagnostics</a></li>
</ul>
<p class="caption"><span class="caption-text">Graphs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="graphs.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="spec.html">Specification</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom-graphs.html">Custom Graphs</a></li>
<li class="toctree-l1"><a class="reference internal" href="optimize.html">Optimization</a></li>
</ul>
<p class="caption"><span class="caption-text">Help & reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="debugging.html">Debugging</a></li>
<li class="toctree-l1"><a class="reference internal" href="support.html">Contact and Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="presentations.html">Presentations On Dask</a></li>
<li class="toctree-l1"><a class="reference internal" href="develop.html">Development Guidelines</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="spark.html">Comparison to PySpark</a></li>
<li class="toctree-l1"><a class="reference internal" href="caching.html">Opportunistic Caching</a></li>
<li class="toctree-l1"><a class="reference internal" href="bytes.html">Internal Data Ingestion</a></li>
<li class="toctree-l1"><a class="reference internal" href="remote-data-services.html">Remote Data Services</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom-collections.html">Custom Collections</a></li>
<li class="toctree-l1"><a class="reference internal" href="cite.html">Citations</a></li>
<li class="toctree-l1"><a class="reference internal" href="funding.html">Funding</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">dask</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li><a href="dataframe.html">DataFrame</a> »</li>
<li>Overview</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/dataframe-overview.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="overview">
<h1>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h1>
<p>Dask Dataframe implements a subset of the Pandas Dataframe interface using
blocked algorithms, cutting up the large DataFrame into many small Pandas
DataFrames. This lets us compute on dataframes that are larger than memory
using all of our cores or on many dataframes spread across a cluster. One
operation on a dask.dataframe triggers many operations on the constituent
Pandas dataframes.</p>
<div class="section" id="design">
<h2>Design<a class="headerlink" href="#design" title="Permalink to this headline">¶</a></h2>
<a class="reference internal image-reference" href="_images/dask-dataframe.svg"><div align="right" class="align-right"><img alt="Dask DataFrames coordinate many Pandas DataFrames" src="_images/dask-dataframe.svg" width="40%" /></div>
</a>
<p>Dask dataframes coordinate many Pandas DataFrames/Series arranged along the
index. Dask.dataframe is partitioned <em>row-wise</em>, grouping rows by index value
for efficiency. These Pandas objects may live on disk or on other machines.</p>
</div>
<div class="section" id="common-uses-and-anti-uses">
<h2>Common Uses and Anti-Uses<a class="headerlink" href="#common-uses-and-anti-uses" title="Permalink to this headline">¶</a></h2>
<p>Dask.dataframe is particularly useful in the following situations:</p>
<ul class="simple">
<li>Manipulating large datasets on a single machine, even when those datasets
don’t fit comfortably into memory.</li>
<li>Fast computation on large workstation machines by parallelizing many Pandas
calls across many cores.</li>
<li>Distributed computing of very large tables stored in the Hadoop File System
(HDFS), S3, or other parallel file systems.</li>
<li>Parallel groupby, join, or time series computations</li>
</ul>
<p>However in the following situations Dask.dataframe may not be the best choice:</p>
<ul class="simple">
<li>If your dataset fits comfortably into RAM on your laptop then you may be
better off just using <a class="reference external" href="https://pandas.pydata.org/">Pandas</a>. There may be simpler ways to improve
performance than through parallelism.</li>
<li>If your dataset doesn’t fit neatly into the Pandas tabular model then you
might find more use in <a class="reference internal" href="bag.html"><span class="doc">dask.bag</span></a> or <a class="reference internal" href="array.html"><span class="doc">dask.array</span></a></li>
<li>If you need functions that are not implemented in dask.dataframe then you
might want to look at <a class="reference internal" href="delayed.html"><span class="doc">dask.delayed</span></a> which offers more
flexibility.</li>
<li>If you need a proper database with all that databases offer you might prefer
something like <a class="reference external" href="https://www.postgresql.org/">Postgres</a></li>
</ul>
</div>
<div class="section" id="dask-dataframe-copies-the-pandas-api">
<h2>Dask.dataframe copies the pandas API<a class="headerlink" href="#dask-dataframe-copies-the-pandas-api" title="Permalink to this headline">¶</a></h2>
<p>Because the <code class="docutils literal"><span class="pre">dask.dataframe</span></code> application programming interface (API) is a
subset of the pandas API it should be familiar to pandas users. There are some
slight alterations due to the parallel nature of dask:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">dask.dataframe</span> <span class="kn">as</span> <span class="nn">dd</span>
<span class="gp">>>> </span><span class="n">df</span> <span class="o">=</span> <span class="n">dd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s1">'2014-*.csv'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">df</span><span class="o">.</span><span class="n">head</span><span class="p">()</span>
<span class="go"> x y</span>
<span class="go">0 1 a</span>
<span class="go">1 2 b</span>
<span class="go">2 3 c</span>
<span class="go">3 4 a</span>
<span class="go">4 5 b</span>
<span class="go">5 6 c</span>
<span class="gp">>>> </span><span class="n">df2</span> <span class="o">=</span> <span class="n">df</span><span class="p">[</span><span class="n">df</span><span class="o">.</span><span class="n">y</span> <span class="o">==</span> <span class="s1">'a'</span><span class="p">]</span><span class="o">.</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<p>As with all dask collections (for example Array, Bag, DataFrame) one triggers
computation by calling the <code class="docutils literal"><span class="pre">.compute()</span></code> method:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">df2</span><span class="o">.</span><span class="n">compute</span><span class="p">()</span>
<span class="go">0 2</span>
<span class="go">3 5</span>
<span class="go">Name: x, dtype: int64</span>
</pre></div>
</div>
</div>
<div class="section" id="scope">
<h2>Scope<a class="headerlink" href="#scope" title="Permalink to this headline">¶</a></h2>
<p>Dask.dataframe covers a small but well-used portion of the pandas API.
This limitation is for two reasons:</p>
<ol class="arabic simple">
<li>The pandas API is <em>huge</em></li>
<li>Some operations are genuinely hard to do in parallel (for example sort).</li>
</ol>
<p>Additionally, some important operations like <code class="docutils literal"><span class="pre">set_index</span></code> work, but are slower
than in pandas because they may write out to disk.</p>
<p>The following class of computations works well:</p>
<ul class="simple">
<li><dl class="first docutils">
<dt>Trivially parallelizable operations (fast):</dt>
<dd><ul class="first last">
<li>Elementwise operations: <code class="docutils literal"><span class="pre">df.x</span> <span class="pre">+</span> <span class="pre">df.y</span></code>, <code class="docutils literal"><span class="pre">df</span> <span class="pre">*</span> <span class="pre">df</span></code></li>
<li>Row-wise selections: <code class="docutils literal"><span class="pre">df[df.x</span> <span class="pre">></span> <span class="pre">0]</span></code></li>
<li>Loc: <code class="docutils literal"><span class="pre">df.loc[4.0:10.5]</span></code></li>
<li>Common aggregations: <code class="docutils literal"><span class="pre">df.x.max()</span></code>, <code class="docutils literal"><span class="pre">df.max()</span></code></li>
<li>Is in: <code class="docutils literal"><span class="pre">df[df.x.isin([1,</span> <span class="pre">2,</span> <span class="pre">3])]</span></code></li>
<li>Datetime/string accessors: <code class="docutils literal"><span class="pre">df.timestamp.month</span></code></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>Cleverly parallelizable operations (fast):</dt>
<dd><ul class="first last">
<li>groupby-aggregate (with common aggregations): <code class="docutils literal"><span class="pre">df.groupby(df.x).y.max()</span></code>,
<code class="docutils literal"><span class="pre">df.groupby('x').max()</span></code></li>
<li>groupby-apply on index: <code class="docutils literal"><span class="pre">df.groupby(['idx',</span> <span class="pre">'x']).apply(myfunc)</span></code>, where
<code class="docutils literal"><span class="pre">idx</span></code> is the index level name</li>
<li>value_counts: <code class="docutils literal"><span class="pre">df.x.value_counts()</span></code></li>
<li>Drop duplicates: <code class="docutils literal"><span class="pre">df.x.drop_duplicates()</span></code></li>
<li>Join on index: <code class="docutils literal"><span class="pre">dd.merge(df1,</span> <span class="pre">df2,</span> <span class="pre">left_index=True,</span> <span class="pre">right_index=True)</span></code></li>
<li>Join with Pandas DataFrames: <code class="docutils literal"><span class="pre">dd.merge(df1,</span> <span class="pre">df2,</span> <span class="pre">on='id')</span></code></li>
<li>Elementwise operations with different partitions / divisions: <code class="docutils literal"><span class="pre">df1.x</span> <span class="pre">+</span> <span class="pre">df2.y</span></code></li>
<li>Datetime resampling: <code class="docutils literal"><span class="pre">df.resample(...)</span></code></li>
<li>Rolling averages: <code class="docutils literal"><span class="pre">df.rolling(...)</span></code></li>
<li>Pearson Correlations: <code class="docutils literal"><span class="pre">df[['col1',</span> <span class="pre">'col2']].corr()</span></code></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>Operations requiring a shuffle (slow-ish, unless on index)</dt>
<dd><ul class="first last">
<li>Set index: <code class="docutils literal"><span class="pre">df.set_index(df.x)</span></code></li>
<li>groupby-apply not on index (with anything): <code class="docutils literal"><span class="pre">df.groupby(df.x).apply(myfunc)</span></code></li>
<li>Join not on the index: <code class="docutils literal"><span class="pre">dd.merge(df1,</span> <span class="pre">df2,</span> <span class="pre">on='name')</span></code></li>
</ul>
</dd>
</dl>
</li>
</ul>
<p>See <a class="reference internal" href="dataframe-api.html"><span class="doc">DataFrame API documentation</span></a> for a more extensive
list.</p>
</div>
<div class="section" id="execution">
<h2>Execution<a class="headerlink" href="#execution" title="Permalink to this headline">¶</a></h2>
<p>By default <code class="docutils literal"><span class="pre">dask.dataframe</span></code> uses the multi-threaded scheduler.
This exposes some parallelism when pandas or the underlying numpy operations
release the global interpreter lock (GIL). Generally pandas is more GIL
bound than NumPy, so multi-core speed-ups are not as pronounced for
<code class="docutils literal"><span class="pre">dask.dataframe</span></code> as they are for <code class="docutils literal"><span class="pre">dask.array</span></code>. This is changing, and
the pandas development team is actively working on releasing the GIL.</p>
<p>In some cases you may experience speedups by switching to the multiprocessing
or distributed scheduler.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dask</span><span class="o">.</span><span class="n">set_options</span><span class="p">(</span><span class="n">get</span><span class="o">=</span><span class="n">dask</span><span class="o">.</span><span class="n">multiprocessing</span><span class="o">.</span><span class="n">get</span><span class="p">)</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="scheduler-overview.html"><span class="doc">scheduler docs</span></a> for more information.</p>
</div>
<div class="section" id="limitations">
<h2>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h2>
<p>Dask.DataFrame does not implement the entire Pandas interface. Users expecting this
will be disappointed. Notably, dask.dataframe has the following limitations:</p>
<ol class="arabic simple">
<li>Setting a new index from an unsorted column is expensive</li>
<li>Many operations, like groupby-apply and join on unsorted columns require
setting the index, which as mentioned above, is expensive</li>
<li>The Pandas API is very large. Dask.dataframe does not attempt to implement
many pandas features or any of the more exotic data structures like NDFrames</li>
</ol>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="dataframe-create.html" class="btn btn-neutral float-right" title="Create and Store Dask DataFrames" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="dataframe.html" class="btn btn-neutral" title="DataFrame" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2017, Anaconda.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'0.16.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="file:///usr/share/javascript/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|