MCPcopy Create free account
hub / github.com/dask/dask / info

Method info

dask/dataframe/dask_expr/_collection.py:3995–4069  ·  view source on GitHub ↗

Concise summary of a Dask DataFrame

(self, buf=None, verbose=False, memory_usage=False)

Source from the content-addressed store, hash-verified

3993 return out
3994
3995 def info(self, buf=None, verbose=False, memory_usage=False):
3996 """
3997 Concise summary of a Dask DataFrame
3998 """
3999 if buf is None:
4000 import sys
4001
4002 buf = sys.stdout
4003 lines = [str(type(self)).replace("._collection", "")]
4004
4005 if len(self.columns) == 0:
4006 lines.append(f"{type(self.index._meta).__name__}: 0 entries")
4007 lines.append(f"Empty {type(self).__name__}")
4008 put_lines(buf, lines)
4009 return
4010
4011 # Group and execute the required computations
4012 computations = {}
4013 if verbose:
4014 computations.update({"index": self.index, "count": self.count()})
4015 if memory_usage:
4016 computations["memory_usage"] = self.memory_usage(deep=True, index=True)
4017
4018 computations = dict(zip(computations.keys(), compute(*computations.values())))
4019
4020 if verbose:
4021 import textwrap
4022
4023 index = computations["index"]
4024 counts = computations["count"]
4025 lines.append(index_summary(index))
4026 lines.append(f"Data columns (total {len(self.columns)} columns):")
4027
4028 from pandas.io.formats.printing import pprint_thing
4029
4030 space = max(len(pprint_thing(k)) for k in self.columns) + 1
4031 column_width = max(space, 7)
4032
4033 header = (
4034 textwrap.dedent("""\
4035 # {{column:<{column_width}}} Non-Null Count Dtype
4036 --- {{underl:<{column_width}}} -------------- -----""")
4037 .format(column_width=column_width)
4038 .format(column="Column", underl="------")
4039 )
4040 column_template = textwrap.dedent(f"""\
4041 {{i:^3}} {{name:<{column_width}}} {{count}} non-null {{dtype}}""")
4042 column_info = [
4043 column_template.format(
4044 i=pprint_thing(i),
4045 name=pprint_thing(name),
4046 count=pprint_thing(count),
4047 dtype=pprint_thing(dtype),
4048 )
4049 for i, (name, count, dtype) in enumerate(
4050 # NOTE: Use `counts.values` for cudf support
4051 zip(self.columns, counts.values, self.dtypes)
4052 )

Callers 4

read_bytesFunction · 0.80
open_headFunction · 0.80
test_infoFunction · 0.80
_assert_infoFunction · 0.80

Calls 15

memory_usageMethod · 0.95
put_linesFunction · 0.90
computeFunction · 0.90
index_summaryFunction · 0.90
memory_reprFunction · 0.90
maxFunction · 0.85
splitMethod · 0.80
replaceMethod · 0.45
countMethod · 0.45
keysMethod · 0.45
valuesMethod · 0.45
itemsMethod · 0.45

Tested by 2

test_infoFunction · 0.64
_assert_infoFunction · 0.64