Pandas中DataFrame的属性及方法大全
生活随笔
收集整理的這篇文章主要介紹了
Pandas中DataFrame的属性及方法大全
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
所有屬性
| at | 訪問行/列標簽對的單個值。 |
| attrs | 此對象的全局屬性字典。 |
| axes | 返回一個表示DataFrame軸的列表。 |
| columns | DataFrame的列標簽。 |
| dtypes | 返回DataFrame中的dtype。 |
| empty | 指示DataFrame是否為空。 |
| iat | 通過整數位置訪問行/列對的單個值。 |
| iloc | 基于位置的純基于整數位置的索引。 |
| index | DataFrame的索引(行標簽)。 |
| loc | 通過標簽或布爾數組訪問一組行和列。 |
| ndim | 返回一個表示軸數/數組維數的整數。 |
| shape | 返回一個表示DataFrame維數的元組。 |
| size | 返回一個int表示此對象中元素的數量。 |
| style | 返回一個Styler對象。 |
| values | 返回DataFrame的Numpy表示形式。 |
所有方法
| abs() | 返回具有每個元素的絕對數值的Series / DataFrame。 |
| add(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的加法(二進制運算符add)。 |
| add_prefix(prefix) | 帶字符串前綴的前綴標簽。 |
| add_suffix(suffix) | 帶字符串后綴的后綴標簽。 |
| agg([func, axis]) | 使用指定軸上的一項或多項操作進行匯總。 |
| aggregate([func, axis]) | 使用指定軸上的一項或多項操作進行匯總。 |
| align(other[, join, axis, level, copy, …]) | 使用指定的join方法將兩個對象在其軸上對齊。 |
| all([axis, bool_only, skipna, level]) | 返回是否所有元素都為True(可能在某個軸上)。 |
| any([axis, bool_only, skipna, level]) | 返回是否有任何元素為True(可能在某個軸上)。 |
| append(other[, ignore_index, …]) | 將其他行附加到調用方的末尾,返回一個新對象。 |
| apply(func[, axis, raw, result_type, args]) | 沿DataFrame的軸應用功能。 |
| applymap(func) | 將函數應用于元素的數據框。 |
| asfreq(freq[, method, how, normalize, …]) | 將TimeSeries轉換為指定的頻率。 |
| asof(where[, subset]) | 返回在此之前沒有任何NaN的最后一行。 |
| assign(**kwargs) | 將新列分配給DataFrame。 |
| astype(dtype[, copy, errors]) | 將熊貓對象轉換為指定的dtype dtype。 |
| at_time(time[, asof, axis]) | 選擇一天中特定時間的值(例如,上午9:30)。 |
| backfill([axis, inplace, limit, downcast]) | DataFrame.fillna()的同義詞,帶有method =‘bfill’。 |
| between_time(start_time, end_time[, …]) | 選擇一天中特定時間之間的值(例如9:00-9:30 AM)。 |
| bfill([axis, inplace, limit, downcast]) | DataFrame.fillna()的同義詞,帶有method =‘bfill’。 |
| bool() | 返回單個元素Series或DataFrame的布爾值。 |
| boxplot([column, by, ax, fontsize, rot, …]) | 從DataFrame列制作箱形圖。 |
| clip([lower, upper, axis, inplace]) | 修剪輸入閾值處的值。 |
| combine(other, func[, fill_value, overwrite]) | 與另一個DataFrame進行按列合并。 |
| combine_first(other) | 在其他位置的相同位置更新具有值的空元素。 |
| compare(other[, align_axis, keep_shape, …]) | 與另一個DataFrame進行比較并顯示差異。 |
| convert_dtypes([infer_objects, …]) | 使用支持pd.NA的dtypes將列轉換為最佳的dtypes。 |
| copy([deep]) | 復制該對象的索引和數據。 |
| corr([method, min_periods]) | 計算列的成對相關,不包括NA /空值。 |
| corrwith(other[, axis, drop, method]) | 計算成對相關。 |
| count([axis, level, numeric_only]) | 為每一列或每一行計算非NA單元。 |
| cov([min_periods, ddof]) | 計算列的成對協方差,不包括NA /空值。 |
| cummax([axis, skipna]) | 返回DataFrame或Series軸上的累積最大值。 |
| cummin([axis, skipna]) | 返回DataFrame或Series軸上的累積最小值。 |
| cumprod([axis, skipna]) | 通過DataFrame或Series軸返回累積乘積。 |
| cumsum([axis, skipna]) | 返回DataFrame或Series軸上的累積總和。 |
| describe([percentiles, include, exclude, …]) | 生成描述性統計信息。 |
| diff([periods, axis]) | 元素的第一個離散差。 |
| div(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的浮點除法(二進制運算符truediv)。 |
| divide(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的浮點除法(二進制運算符truediv)。 |
| dot(other) | 計算DataFrame與其他框架之間的矩陣乘法。 |
| drop([labels, axis, index, columns, level, …]) | 從行或列中刪除指定的標簽。 |
| drop_duplicates([subset, keep, inplace, …]) | 返回刪除重復行的DataFrame。 |
| droplevel(level[, axis]) | 返回已刪除請求的索引/列級別的DataFrame。 |
| dropna([axis, how, thresh, subset, inplace]) | 刪除缺失的值。 |
| duplicated([subset, keep]) | 返回表示重復行的布爾系列。 |
| eq(other[, axis, level]) | 等于等于數據幀和其他按元素計算(二進制運算符eq)。 |
| equals(other) | 測試兩個對象是否包含相同的元素。 |
| eval(expr[, inplace]) | 評估描述DataFrame列上的操作的字符串。 |
| ewm([com, span, halflife, alpha, …]) | 提供指數加權(EW)函數。 |
| expanding([min_periods, center, axis]) | 提供擴展的轉換。 |
| explode(column[, ignore_index]) | 將類似列表的每個元素轉換為一行,復制索引值。 |
| ffill([axis, inplace, limit, downcast]) | DataFrame.fillna()的同義詞,方法=‘ffill’。 |
| fillna([value, method, axis, inplace, …]) | 使用指定的方法填充NA / NaN值。 |
| filter([items, like, regex, axis]) | 根據指定的索引標簽對數據框的行或列進行子集設置。 |
| first(offset) | 根據日期偏移量選擇時間序列數據的初始時段。 |
| first_valid_index() | 返回第一個非NA /空值的索引。 |
| floordiv(other[, axis, level, fill_value]) | 獲取數據幀的整數除法和其他逐元素的方法(二進制運算符florordiv)。 |
| from_dict(data[, orient, dtype, columns]) | 從類似數組或字典的字典構造DataFrame。 |
| from_records(data[, index, exclude, …]) | 將結構化或記錄ndarray轉換為DataFrame。 |
| ge(other[, axis, level]) | 獲取大于或等于數據幀和其他逐元素的值(二進制運算符ge)。 |
| get(key[, default]) | 從對象獲取給定鍵的項目(例如:DataFrame列)。 |
| groupby([by, axis, level, as_index, sort, …]) | 使用映射器或按一系列列對DataFrame進行分組。 |
| gt(other[, axis, level]) | 獲取大于dataframe和其他逐個元素的值(二進制運算符>)。 |
| head([n]) | 返回前n行 |
| hist([column, by, grid, xlabelsize, xrot, …]) | 制作DataFrame的直方圖。 |
| idxmax([axis, skipna]) | 返回在請求軸上第一次出現最大值的索引。 |
| idxmin([axis, skipna]) | 在請求的軸上第一次出現最小值的返回索引。 |
| infer_objects() | 嘗試為對象列推斷更好的dtype。 |
| info([verbose, buf, max_cols, memory_usage, …]) | 打印DataFrame的簡要摘要。 |
| insert(loc, column, value[, allow_duplicates]) | 將列插入DataFrame中的指定位置。 |
| interpolate([method, axis, limit, inplace, …]) | 請注意,具有MultiIndex的DataFrame / Series僅支持method =‘linear’。 |
| isin(values) | DataFrame中的每個元素是否包含在值中。 |
| isna() | 檢測缺失值。 |
| isnull() | 檢測缺失值。 |
| items() | 遍歷(列名,系列)對。 |
| iteritems() | 遍歷(列名,系列)對。 |
| iterrows() | 將DataFrame行作為(索引,系列)對進行迭代。 |
| itertuples([index, name]) | 以namedtuple的形式遍歷DataFrame行。 |
| join(other[, on, how, lsuffix, rsuffix, sort]) | 連接另一個DataFrame的列。 |
| keys() | 獲取“信息軸”(有關更多信息,請參見索引)。 |
| kurt([axis, skipna, level, numeric_only]) | 在請求的軸上返回無偏峰度。 |
| kurtosis([axis, skipna, level, numeric_only]) | 在請求的軸上返回無偏峰度。 |
| last(offset) | 根據日期偏移量選擇時間序列數據的最后時段。 |
| last_valid_index() | 返回上一個非NA /空值的索引。 |
| le(other[, axis, level]) | 小于或等于dataframe和其他逐元素(二進制運算符)。 |
| lookup(row_labels, col_labels) | DataFrame基于標簽的“花式索引”功能。 |
| lt(other[, axis, level]) | 獲取小于dataframe和其他元素級數(二進制運算符lt)。 |
| mad([axis, skipna, level]) | 返回所請求軸的值的平均絕對偏差。 |
| mask(cond[, other, inplace, axis, level, …]) | 替換條件為True的值。 |
| max([axis, skipna, level, numeric_only]) | 返回所請求軸的最大值。 |
| mean([axis, skipna, level, numeric_only]) | 返回值的平均值 |
| median([axis, skipna, level, numeric_only]) | 返回所請求軸的值的中值。 |
| melt([id_vars, value_vars, var_name, …]) | 取消將DataFrame從寬格式轉為長格式,可以選擇保留標識符。 |
| memory_usage([index, deep]) | 返回每列的內存使用情況(以字節為單位)。 |
| merge(right[, how, on, left_on, right_on, …]) | 用數據庫樣式的聯接合并DataFrame或命名的Series對象。 |
| min([axis, skipna, level, numeric_only]) | 返回所請求軸的最小值。 |
| mod(other[, axis, level, fill_value]) | 獲取數據幀的Modulo以及其他按元素的方式(二進制運算符mod)。 |
| mode([axis, numeric_only, dropna]) | 獲取沿選定軸的每個元素的模式。 |
| mul(other[, axis, level, fill_value]) | 獲取數據幀和其他逐元素的乘法(二進制運算符mul)。 |
| multiply(other[, axis, level, fill_value]) | 獲取數據幀和其他逐元素的乘法(二進制運算符mul)。 |
| ne(other[, axis, level]) | 獲取不等于dataframe的值以及其他逐元素的值(二進制運算符ne)。 |
| nlargest(n, columns[, keep]) | 按降序返回按列排序的前n行。 |
| notna() | 檢測現有(非缺失)值。 |
| notnull() | 檢測現有(非缺失)值。 |
| nsmallest(n, columns[, keep]) | 按升序返回列排序的前n行。 |
| nunique([axis, dropna]) | 計算請求軸上的不同觀察值。 |
| pad([axis, inplace, limit, downcast]) | DataFrame.fillna()的同義詞,方法=‘ffill’。 |
| pct_change([periods, fill_method, limit, freq]) | 當前元素與先前元素之間的百分比變化。 |
| pipe(func, *args, **kwargs) | 應用func(self,* args,** kwargs)。 |
| pivot([index, columns, values]) | 返回按給定的索引/列值組織的重整型DataFrame。 |
| pivot_table([values, index, columns, …]) | 創建電子表格樣式的數據透視表作為DataFrame。 |
| plot | pandas.plotting._core.PlotAccessor的別名 |
| pop(item) | 返回項目并從框架中放下。 |
| pow(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的指數冪(二進制運算符pow)。 |
| prod([axis, skipna, level, numeric_only, …]) | 返回所請求軸的值的乘積。 |
| product([axis, skipna, level, numeric_only, …]) | 返回所請求軸的值的乘積。 |
| quantile([q, axis, numeric_only, interpolation]) | 在請求的軸上以給定的分位數返回值。 |
| query(expr[, inplace]) | 使用布爾表達式查詢DataFrame的列。 |
| radd(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的加法(二進制運算符radd)。 |
| rank([axis, method, numeric_only, …]) | 沿軸計算數值數據等級(1到n)。 |
| rdiv(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的浮點除法(二進制運算符rtruediv)。 |
| reindex(**kwargs) | 使用可選的填充邏輯使Series / DataFrame與新索引一致。 |
| reindex_like(other[, method, copy, limit, …]) | 返回具有匹配索引的對象作為其他對象。 |
| rename(**kwargs) | 更改軸標簽。 |
| rename_axis(**kwargs) | 設置索引或列的軸名稱。 |
| reorder_levels(order[, axis]) | 使用輸入順序重新排列索引級別。 |
| replace([to_replace, value, inplace, limit, …]) | 將to_replace中給定的值替換為value。 |
| resample(rule[, axis, closed, label, …]) | 重新采樣時間序列數據。 |
| reset_index([level, drop, inplace, …]) | 重置索引或索引的級別。 |
| rfloordiv(other[, axis, level, fill_value]) | 獲取數據幀的整數除法和其他逐元素的方法(二進制運算符rfloordiv)。 |
| rmod(other[, axis, level, fill_value]) | 獲取數據幀的Modulo以及其他按元素的方式(二進制運算符rmod)。 |
| rmul(other[, axis, level, fill_value]) | 獲取數據幀和其他逐元素的乘法(二進制運算符rmul)。 |
| rolling(window[, min_periods, center, …]) | 提供滾動窗口計算。 |
| round([decimals]) | 將DataFrame舍入到小數位數可變。 |
| rpow(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的指數冪(二進制運算符rpow)。 |
| rsub(other[, axis, level, fill_value]) | 獲取數據幀的減法和其他逐元素的方法(二進制運算符rsub)。 |
| rtruediv(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的浮點除法(二進制運算符rtruediv)。 |
| sample([n, frac, replace, weights, …]) | 從對象軸返回隨機的項目樣本。 |
| select_dtypes([include, exclude]) | 根據列dtypes返回DataFrame列的子集。 |
| sem([axis, skipna, level, ddof, numeric_only]) | 返回要求軸上的平均值的無偏標準誤差。 |
| set_axis(labels[, axis, inplace]) | 將所需的索引分配給給定軸。 |
| set_index(keys[, drop, append, inplace, …]) | 使用現有列設置DataFrame索引。 |
| shift([periods, freq, axis, fill_value]) | 按所需的周期數移動索引,并帶有可選的時間頻率。 |
| skew([axis, skipna, level, numeric_only]) | 在請求的軸上返回無偏斜。 |
| slice_shift([periods, axis]) | 相當于移位而不復制數據。 |
| sort_index([axis, level, ascending, …]) | 按標簽(沿軸)對對象排序。 |
| sort_values(by[, axis, ascending, inplace, …]) | 沿任一軸的值排序。 |
| sparse | pandas.core.arrays.sparse.accessor.SparseFrameAccessor的別名 |
| squeeze([axis]) | 將一維軸對象壓縮為標量。 |
| stack([level, dropna]) | 從列到索引堆疊指定級別。 |
| std([axis, skipna, level, ddof, numeric_only]) | 返回要求軸上的樣品標準偏差。 |
| sub(other[, axis, level, fill_value]) | 獲取數據幀的減法和其他逐元素的方法(二進制運算符sub)。 |
| subtract(other[, axis, level, fill_value]) | 獲取數據幀的減法和其他逐元素的方法(二進制運算符sub)。 |
| sum([axis, skipna, level, numeric_only, …]) | 返回所請求軸的值之和。 |
| swapaxes(axis1, axis2[, copy]) | 適當地交換軸和交換值軸。 |
| swaplevel([i, j, axis]) | 在特定軸上的MultiIndex中交換級別i和j。 |
| tail([n]) | 返回最后一行 |
| take(indices[, axis, is_copy]) | 沿軸返回給定位置索引中的元素。 |
| to_clipboard([excel, sep]) | 將對象復制到系統剪貼板。 |
| to_csv([path_or_buf, sep, na_rep, …]) | 將對象寫入逗號分隔值(csv)文件。 |
| to_dict([orient, into]) | 將DataFrame轉換為字典。 |
| to_excel(excel_writer[, sheet_name, na_rep, …]) | 將對象寫入Excel工作表。 |
| to_feather(**kwargs) | 將DataFrame寫入二進制Feather格式。 |
| to_gbq(destination_table[, project_id, …]) | 將DataFrame寫入Google BigQuery表。 |
| to_hdf(path_or_buf, key[, mode, complevel, …]) | 使用HDFStore將包含的數據寫入HDF5文件。 |
| to_html([buf, columns, col_space, header, …]) | 將DataFrame呈現為HTML表。 |
| to_json([path_or_buf, orient, date_format, …]) | 將對象轉換為JSON字符串。 |
| to_latex([buf, columns, col_space, header, …]) | 將對象渲染為LaTeX表格,長表或嵌套表/表格。 |
| to_markdown([buf, mode, index]) | 以Markdown友好格式打印DataFrame。 |
| to_numpy([dtype, copy, na_value]) | 將DataFrame轉換為NumPy數組。 |
| to_parquet(**kwargs) | 將DataFrame寫入二進制拼花格式。 |
| to_period([freq, axis, copy]) | 將DataFrame從DatetimeIndex轉換為PeriodIndex。 |
| to_pickle(path[, compression, protocol]) | 將對象腌制(序列化)到文件。 |
| to_records([index, column_dtypes, index_dtypes]) | 將DataFrame轉換為NumPy記錄數組。 |
| to_sql(name, con[, schema, if_exists, …]) | 將存儲在DataFrame中的記錄寫入SQL數據庫。 |
| to_stata(**kwargs) | 將DataFrame對象導出為Stata dta格式。 |
| to_string([buf, columns, col_space, header, …]) | 將DataFrame渲染到控制臺友好的表格輸出。 |
| to_timestamp([freq, how, axis, copy]) | 在時段開始時將其強制轉換為時間戳的DatetimeIndex。 |
| to_xarray() | 從pandas對象返回一個xarray對象。 |
| transform(func[, axis]) | 自我調用func產生具有轉換值的DataFrame。 |
| transpose(*args[, copy]) | 轉置索引和列。 |
| truediv(other[, axis, level, fill_value]) | 獲取數據幀和其他元素的浮點除法(二進制運算符或truediv)。 |
| truncate([before, after, axis, copy]) | 在某個索引值之前和之后截斷Series或DataFrame。 |
| tshift([periods, freq, axis]) | (已棄用)使用時標頻率(如果有)移動時間索引。 |
| tz_convert(tz[, axis, level, copy]) | 將可感知tz的軸轉換為目標時區。 |
| tz_localize(tz[, axis, level, copy, …]) | 將Series或DataFrame的tz天真索引本地化為目標時區。 |
| unstack([level, fill_value]) | 樞轉一個級別(必要的層次結構)索引標簽。 |
| update(other[, join, overwrite, …]) | 使用來自另一個DataFrame的非NA值就地進行修改。 |
| value_counts([subset, normalize, sort, …]) | 返回一個包含DataFrame中唯一行數的Series。 |
| var([axis, skipna, level, ddof, numeric_only]) | 返回請求軸上的無偏方差。 |
| where(cond[, other, inplace, axis, level, …]) | 替換條件為False的值。 |
| xs(key[, axis, level, drop_level]) | 從Series / DataFrame返回橫截面。 |
總結
以上是生活随笔為你收集整理的Pandas中DataFrame的属性及方法大全的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pandas缺失数据最快定位方式(极少代
- 下一篇: Pandas简明教程:五、Pandas简