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

Class DataFrame

dask/dataframe/dask_expr/_collection.py:2723–4129  ·  view source on GitHub ↗

DataFrame-like Expr Collection. The constructor takes the expression that represents the query as input. The class is not meant to be instantiated directly. Instead, use one of the IO connectors from Dask.

Source from the content-addressed store, hash-verified

2721
2722
2723class DataFrame(FrameBase):
2724 """DataFrame-like Expr Collection.
2725
2726 The constructor takes the expression that represents the query as input. The class
2727 is not meant to be instantiated directly. Instead, use one of the IO connectors from
2728 Dask.
2729 """
2730
2731 _accessors: ClassVar[set[str]] = set()
2732 _partition_type = pd.DataFrame
2733
2734 @property
2735 def shape(self):
2736 return self.size // max(len(self.columns), 1), len(self.columns)
2737
2738 @property
2739 def ndim(self):
2740 """Return dimensionality"""
2741 return 2
2742
2743 @property
2744 def empty(self):
2745 # __getattr__ will be called after we raise this, so we'll raise it again from there
2746 raise AttributeNotImplementedError(
2747 "Checking whether a Dask DataFrame has any rows may be expensive. "
2748 "However, checking the number of columns is fast. "
2749 "Depending on which of these results you need, use either "
2750 "`len(df.index) == 0` or `len(df.columns) == 0`"
2751 )
2752
2753 @derived_from(pd.DataFrame)
2754 def items(self):
2755 for i, name in enumerate(self.columns):
2756 yield (name, self.iloc[:, i])
2757
2758 @property
2759 def axes(self):
2760 return [self.index, self.columns]
2761
2762 def __contains__(self, key):
2763 return key in self._meta
2764
2765 def __iter__(self):
2766 return iter(self._meta)
2767
2768 def __dataframe__(self, *args, **kwargs):
2769 from dask.dataframe.dask_expr._interchange import DaskDataFrameInterchange
2770
2771 return DaskDataFrameInterchange(self)
2772
2773 @derived_from(pd.DataFrame)
2774 def iterrows(self):
2775 frame = self.optimize()
2776 for i in range(self.npartitions):
2777 df = frame.get_partition(i).compute()
2778 yield from df.iterrows()
2779
2780 @derived_from(pd.DataFrame)

Callers

nothing calls this directly

Calls 1

setClass · 0.85

Tested by

no test coverage detected