2022年7月28日 星期四

titanic_0009:物件(object)

 titanic_0009:物件(object)

2022/07/14

說明:


-----

https://pixabay.com/zh/photos/umbrella-only-sad-depression-2603980/

-----


Fig. 1. Object [1].

-----

「Pandas dtype Python type NumPy type Usage

object str or mixed string_, unicode_, mixed types Text or mixed numeric and non-numeric values」[1]。

-----

「The dtype object comes from NumPy, it describes the type of element in a ndarray. Every element in an ndarray must have the same size in bytes. For int64 and float64, they are 8 bytes. But for strings, the length of the string is not fixed. So instead of saving the bytes of strings in the ndarray directly, Pandas uses an object ndarray, which saves pointers to objects; because of this the dtype of this kind ndarray is object.」[2]。

「dtype 物件來自 NumPy,它描述了 ndarray 中元素的類型。 ndarray 中的每個元素必須具有相同的位元組大小。 對於 int64 和 float64,它們是 8 個位元組。 但是對於字串來說,字串的長度是不固定的。 因此,Pandas 沒有直接將字串的位元組保存在 ndarray 中,而是使用了一個物件 ndarray,它保存了指向物件的指標; 因此,這種 ndarray 的 dtype 是物件。」

-----

# Structured Array

「At the very basic level, Pandas objects can be thought of as enhanced versions of NumPy structured arrays in which the rows and columns are identified with labels rather than simple integer indices.」[3]。

「在最基本的層面上,Pandas 物件可以被認為是 NumPy 結構化陣列的增強版本,其中列和行用標籤而不是簡單的整數索引來標識。」

-----

# Tensor to Numpy

「In general, if an object can be converted to a tensor with tf.convert_to_tensor it can be passed anywhere you can pass a tf.Tensor.」[4]。

「一般來說,如果一個物件可以使用 tf.convert_to_tensor 轉換為張量,則它可以在任何可以傳遞 tf.Tensor 的地方傳遞。」

-----

References


# dtype

[1] Overview of Pandas Data Types - Practical Business Python

https://pbpython.com/pandas_dtypes.html


# string

[2] python - Strings in a DataFrame, but dtype is object - Stack Overflow

https://stackoverflow.com/questions/21018654/strings-in-a-dataframe-but-dtype-is-object


# Series、DataFrame、Index

[3] 03.01-Introducing-Pandas-Objects.ipynb - Colaboratory

https://colab.research.google.com/github/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/03.01-Introducing-Pandas-Objects.ipynb


# DataFrame

[4] Load a pandas DataFrame  |  TensorFlow Core

https://www.tensorflow.org/tutorials/load_data/pandas_dataframe


# Series、DataFrame、Index

[5] Introducing Pandas Objects | Python Data Science Handbook

https://jakevdp.github.io/PythonDataScienceHandbook/03.01-introducing-pandas-objects.html


# Series、DataFrame

[6] Python Pandas Objects - Pandas Series and Pandas Dataframe-SaralGyaan

https://saralgyaan.com/posts/pandas-objects-series-and-dataframe/


# dtype

[7] 在 Pandas 中把物件轉換為浮點型 | D棧 - Delft Stack

https://www.delftstack.com/zh-tw/howto/python-pandas/pandas-convert-object-to-float/


# dtype

[8] 如何在 Pandas 中更改列的資料型別 | D棧 - Delft Stack

https://www.delftstack.com/zh-tw/howto/python-pandas/how-to-change-data-type-of-columns-in-pandas/


# mixed

[9] Pandas: Clean object column with mixed data of a given DataFrame using regular expression - w3resource

https://www.w3resource.com/python-exercises/pandas/python-pandas-data-frame-exercise-76.php


# mixed

[10] python - Mixed types of elements in DataFrame's column - Stack Overflow

https://stackoverflow.com/questions/27362234/mixed-types-of-elements-in-dataframes-column

-----

Pandas(目錄)

https://mandhistory.blogspot.com/2022/05/pandas.html

-----

鐵達尼號 Python 實作(目錄)

https://mandhistory.blogspot.com/2022/06/titanic.html

-----

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。