Struct PyDataFrame

Source
#[repr(transparent)]
pub struct PyDataFrame { pub df: DataFrame, }

Fields§

§df: DataFrame

Implementations§

Source§

impl PyDataFrame

Source

pub fn from_rows( py: Python<'_>, data: Vec<Wrap<Row<'_>>>, schema: Option<Wrap<Schema>>, infer_schema_length: Option<usize>, ) -> PyResult<Self>

Source

pub fn from_dicts( py: Python<'_>, data: &Bound<'_, PyAny>, schema: Option<Wrap<Schema>>, schema_overrides: Option<Wrap<Schema>>, strict: bool, infer_schema_length: Option<usize>, ) -> PyResult<Self>

Source

pub fn from_arrow_record_batches( py: Python<'_>, rb: Vec<Bound<'_, PyAny>>, schema: Bound<'_, PyAny>, ) -> PyResult<Self>

Source§

impl PyDataFrame

Source

pub fn row_tuple<'py>( &self, idx: i64, py: Python<'py>, ) -> PyResult<Bound<'py, PyTuple>>

Source

pub fn row_tuples<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyList>>

Source

pub fn to_arrow( &mut self, py: Python<'_>, compat_level: PyCompatLevel, ) -> PyResult<Vec<PyObject>>

Source

pub fn to_pandas(&mut self, py: Python<'_>) -> PyResult<Vec<PyObject>>

Create a Vec of PyArrow RecordBatch instances.

Note this will give bad results for columns with dtype pl.Object, since those can’t be converted correctly via PyArrow. The calling Python code should make sure these are not included.

Source§

impl PyDataFrame

Source

pub fn __init__(columns: Vec<PySeries>) -> PyResult<Self>

Source

pub fn estimated_size(&self) -> usize

Source

pub fn dtype_strings(&self) -> Vec<String>

Source

pub fn add(&self, py: Python<'_>, s: &PySeries) -> PyResult<Self>

Source

pub fn sub(&self, py: Python<'_>, s: &PySeries) -> PyResult<Self>

Source

pub fn div(&self, py: Python<'_>, s: &PySeries) -> PyResult<Self>

Source

pub fn mul(&self, py: Python<'_>, s: &PySeries) -> PyResult<Self>

Source

pub fn rem(&self, py: Python<'_>, s: &PySeries) -> PyResult<Self>

Source

pub fn add_df(&self, py: Python<'_>, s: &Self) -> PyResult<Self>

Source

pub fn sub_df(&self, py: Python<'_>, s: &Self) -> PyResult<Self>

Source

pub fn div_df(&self, py: Python<'_>, s: &Self) -> PyResult<Self>

Source

pub fn mul_df(&self, py: Python<'_>, s: &Self) -> PyResult<Self>

Source

pub fn rem_df(&self, py: Python<'_>, s: &Self) -> PyResult<Self>

Source

pub fn sample_n( &self, py: Python<'_>, n: &PySeries, with_replacement: bool, shuffle: bool, seed: Option<u64>, ) -> PyResult<Self>

Source

pub fn sample_frac( &self, py: Python<'_>, frac: &PySeries, with_replacement: bool, shuffle: bool, seed: Option<u64>, ) -> PyResult<Self>

Source

pub fn rechunk(&self, py: Python<'_>) -> Self

Source

pub fn as_str(&self) -> String

Format DataFrame as String

Source

pub fn get_columns(&self) -> Vec<PySeries>

Source

pub fn columns(&self) -> Vec<&str>

Get column names

Source

pub fn set_column_names(&mut self, names: Vec<PyBackedStr>) -> PyResult<()>

set column names

Source

pub fn dtypes<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyList>>

Get datatypes

Source

pub fn n_chunks(&self) -> usize

Source

pub fn shape(&self) -> (usize, usize)

Source

pub fn height(&self) -> usize

Source

pub fn width(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn hstack(&self, py: Python<'_>, columns: Vec<PySeries>) -> PyResult<Self>

Source

pub fn hstack_mut( &mut self, py: Python<'_>, columns: Vec<PySeries>, ) -> PyResult<()>

Source

pub fn vstack(&self, py: Python<'_>, other: &PyDataFrame) -> PyResult<Self>

Source

pub fn vstack_mut( &mut self, py: Python<'_>, other: &PyDataFrame, ) -> PyResult<()>

Source

pub fn extend(&mut self, py: Python<'_>, other: &PyDataFrame) -> PyResult<()>

Source

pub fn drop_in_place(&mut self, name: &str) -> PyResult<PySeries>

Source

pub fn to_series(&self, index: isize) -> PyResult<PySeries>

Source

pub fn get_column_index(&self, name: &str) -> PyResult<usize>

Source

pub fn get_column(&self, name: &str) -> PyResult<PySeries>

Source

pub fn select( &self, py: Python<'_>, columns: Vec<PyBackedStr>, ) -> PyResult<Self>

Source

pub fn gather( &self, py: Python<'_>, indices: Wrap<Vec<IdxSize>>, ) -> PyResult<Self>

Source

pub fn gather_with_series( &self, py: Python<'_>, indices: &PySeries, ) -> PyResult<Self>

Source

pub fn replace(&mut self, column: &str, new_col: PySeries) -> PyResult<()>

Source

pub fn replace_column( &mut self, index: usize, new_column: PySeries, ) -> PyResult<()>

Source

pub fn insert_column(&mut self, index: usize, column: PySeries) -> PyResult<()>

Source

pub fn slice(&self, py: Python<'_>, offset: i64, length: Option<usize>) -> Self

Source

pub fn head(&self, py: Python<'_>, n: usize) -> Self

Source

pub fn tail(&self, py: Python<'_>, n: usize) -> Self

Source

pub fn is_unique(&self, py: Python<'_>) -> PyResult<PySeries>

Source

pub fn is_duplicated(&self, py: Python<'_>) -> PyResult<PySeries>

Source

pub fn equals( &self, py: Python<'_>, other: &PyDataFrame, null_equal: bool, ) -> bool

Source

pub fn with_row_index( &self, py: Python<'_>, name: &str, offset: Option<IdxSize>, ) -> PyResult<Self>

Source

pub fn _to_metadata(&self) -> Self

Source

pub fn group_by_map_groups( &self, by: Vec<PyBackedStr>, lambda: PyObject, maintain_order: bool, ) -> PyResult<Self>

Source

pub fn clone(&self) -> Self

Source

pub fn unpivot( &self, py: Python<'_>, on: Vec<PyBackedStr>, index: Vec<PyBackedStr>, value_name: Option<&str>, variable_name: Option<&str>, ) -> PyResult<Self>

Source

pub fn pivot_expr( &self, py: Python<'_>, on: Vec<String>, index: Option<Vec<String>>, values: Option<Vec<String>>, maintain_order: bool, sort_columns: bool, aggregate_expr: Option<PyExpr>, separator: Option<&str>, ) -> PyResult<Self>

Source

pub fn partition_by( &self, py: Python<'_>, by: Vec<String>, maintain_order: bool, include_key: bool, ) -> PyResult<Vec<Self>>

Source

pub fn lazy(&self) -> PyLazyFrame

Source

pub fn to_dummies( &self, py: Python<'_>, columns: Option<Vec<String>>, separator: Option<&str>, drop_first: bool, ) -> PyResult<Self>

Source

pub fn null_count(&self, py: Python<'_>) -> Self

Source

pub fn map_rows( &mut self, lambda: Bound<'_, PyAny>, output_type: Option<Wrap<DataType>>, inference_size: usize, ) -> PyResult<(PyObject, bool)>

Source

pub fn shrink_to_fit(&mut self, py: Python<'_>)

Source

pub fn hash_rows( &mut self, py: Python<'_>, k0: u64, k1: u64, k2: u64, k3: u64, ) -> PyResult<PySeries>

Source

pub fn transpose( &mut self, py: Python<'_>, keep_names_as: Option<&str>, column_names: &Bound<'_, PyAny>, ) -> PyResult<Self>

Source

pub fn upsample( &self, py: Python<'_>, by: Vec<String>, index_column: &str, every: &str, stable: bool, ) -> PyResult<Self>

Source

pub fn to_struct( &self, py: Python<'_>, name: &str, invalid_indices: Vec<usize>, ) -> PySeries

Source

pub fn clear(&self, py: Python<'_>) -> Self

Source

pub fn into_raw_parts(&mut self) -> (usize, usize, usize)

Source§

impl PyDataFrame

Source

pub fn read_csv( py: Python<'_>, py_f: Bound<'_, PyAny>, infer_schema_length: Option<usize>, chunk_size: usize, has_header: bool, ignore_errors: bool, n_rows: Option<usize>, skip_rows: usize, skip_lines: usize, projection: Option<Vec<usize>>, separator: &str, rechunk: bool, columns: Option<Vec<String>>, encoding: Wrap<CsvEncoding>, n_threads: Option<usize>, path: Option<String>, overwrite_dtype: Option<Vec<(PyBackedStr, Wrap<DataType>)>>, overwrite_dtype_slice: Option<Vec<Wrap<DataType>>>, low_memory: bool, comment_prefix: Option<&str>, quote_char: Option<&str>, null_values: Option<Wrap<NullValues>>, missing_utf8_is_empty_string: bool, try_parse_dates: bool, skip_rows_after_header: usize, row_index: Option<(String, IdxSize)>, eol_char: &str, raise_if_empty: bool, truncate_ragged_lines: bool, decimal_comma: bool, schema: Option<Wrap<Schema>>, ) -> PyResult<Self>

Source

pub fn read_parquet( py: Python<'_>, py_f: PyObject, columns: Option<Vec<String>>, projection: Option<Vec<usize>>, n_rows: Option<usize>, row_index: Option<(String, IdxSize)>, low_memory: bool, parallel: Wrap<ParallelStrategy>, use_statistics: bool, rechunk: bool, ) -> PyResult<Self>

Source

pub fn read_json( py: Python<'_>, py_f: Bound<'_, PyAny>, infer_schema_length: Option<usize>, schema: Option<Wrap<Schema>>, schema_overrides: Option<Wrap<Schema>>, ) -> PyResult<Self>

Source

pub fn read_ndjson( py: Python<'_>, py_f: Bound<'_, PyAny>, ignore_errors: bool, schema: Option<Wrap<Schema>>, schema_overrides: Option<Wrap<Schema>>, ) -> PyResult<Self>

Source

pub fn read_ipc( py: Python<'_>, py_f: Bound<'_, PyAny>, columns: Option<Vec<String>>, projection: Option<Vec<usize>>, n_rows: Option<usize>, row_index: Option<(String, IdxSize)>, memory_map: bool, ) -> PyResult<Self>

Source

pub fn read_ipc_stream( py: Python<'_>, py_f: Bound<'_, PyAny>, columns: Option<Vec<String>>, projection: Option<Vec<usize>>, n_rows: Option<usize>, row_index: Option<(String, IdxSize)>, rechunk: bool, ) -> PyResult<Self>

Source

pub fn read_avro( py: Python<'_>, py_f: PyObject, columns: Option<Vec<String>>, projection: Option<Vec<usize>>, n_rows: Option<usize>, ) -> PyResult<Self>

Source

pub fn write_csv( &mut self, py: Python<'_>, py_f: PyObject, include_bom: bool, include_header: bool, separator: u8, line_terminator: String, quote_char: u8, batch_size: NonZeroUsize, datetime_format: Option<String>, date_format: Option<String>, time_format: Option<String>, float_scientific: Option<bool>, float_precision: Option<usize>, null_value: Option<String>, quote_style: Option<Wrap<QuoteStyle>>, cloud_options: Option<Vec<(String, String)>>, credential_provider: Option<PyObject>, retries: usize, ) -> PyResult<()>

Source

pub fn write_parquet( &mut self, py: Python<'_>, py_f: PyObject, compression: &str, compression_level: Option<i32>, statistics: Wrap<StatisticsOptions>, row_group_size: Option<usize>, data_page_size: Option<usize>, partition_by: Option<Vec<String>>, partition_chunk_size_bytes: usize, cloud_options: Option<Vec<(String, String)>>, credential_provider: Option<PyObject>, retries: usize, ) -> PyResult<()>

Source

pub fn write_json(&mut self, py_f: PyObject) -> PyResult<()>

Source

pub fn write_ndjson(&mut self, py_f: PyObject) -> PyResult<()>

Source

pub fn write_ipc( &mut self, py: Python<'_>, py_f: PyObject, compression: Wrap<Option<IpcCompression>>, compat_level: PyCompatLevel, cloud_options: Option<Vec<(String, String)>>, credential_provider: Option<PyObject>, retries: usize, ) -> PyResult<()>

Source

pub fn write_ipc_stream( &mut self, py: Python<'_>, py_f: PyObject, compression: Wrap<Option<IpcCompression>>, compat_level: PyCompatLevel, ) -> PyResult<()>

Source

pub fn write_avro( &mut self, py: Python<'_>, py_f: PyObject, compression: Wrap<Option<AvroCompression>>, name: String, ) -> PyResult<()>

Source§

impl PyDataFrame

Source

pub fn serialize_json(&mut self, py: Python<'_>, py_f: PyObject) -> PyResult<()>

Serialize into a JSON string.

Source

pub fn deserialize_json( py: Python<'_>, py_f: Bound<'_, PyAny>, ) -> PyResult<Self>

Deserialize a file-like object containing JSON string data into a DataFrame.

Trait Implementations§

Source§

impl Clone for PyDataFrame

Source§

fn clone(&self) -> PyDataFrame

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<DataFrame> for PyDataFrame

Source§

fn from(df: DataFrame) -> Self

Converts to this type from the input type.
Source§

impl IntoPy<Py<PyAny>> for PyDataFrame

Source§

fn into_py(self, py: Python<'_>) -> PyObject

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23.0/migration) for more information.
Performs the conversion.
Source§

impl<'py> IntoPyObject<'py> for PyDataFrame

Source§

type Target = PyDataFrame

The Python output type
Source§

type Output = Bound<'py, <PyDataFrame as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for PyDataFrame

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for PyDataFrame

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<PyDataFrame>

This handles following two situations: Read more
Source§

type Inventory = Pyo3MethodsInventoryForPyDataFrame

Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature<PyDataFrame> for PyClassImplCollector<PyDataFrame>

Source§

fn new_text_signature(self) -> Option<&'static str>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyDataFrame

Source§

type Holder = Option<PyRef<'py, PyDataFrame>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut PyDataFrame

Source§

type Holder = Option<PyRefMut<'py, PyDataFrame>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyTypeInfo for PyDataFrame

Source§

const NAME: &'static str = "PyDataFrame"

Class name.
Source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
Source§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

👎Deprecated since 0.23.0: renamed to PyTypeInfo::type_object
Deprecated name for PyTypeInfo::type_object.
Source§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_type_of
Deprecated name for PyTypeInfo::is_type_of.
Source§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_exact_type_of
Deprecated name for PyTypeInfo::is_exact_type_of.
Source§

impl DerefToPyAny for PyDataFrame

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

Source§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

Source§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

Source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
Source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Ungil for T
where T: Send,