Pandas commonly used API_1

pandas

Data analysis and processing library
pandas official website
pandas Chinese network


API

Description:
import pandas as pd
df_obj: DataFrame object (table-type data structure, providing ordered columns and different types of column values)
s_obj: series object (one-dimensional array object, containing a set of indexes and a set of data)
1. pd.read_csv (filepath_or_buffer, ...)
  reads the csv file into the DataFrame.
Common parameters:
   filepath_or_buffer : any valid string path; it can also be a URL, valid URL schemes include: http, ftp, s3 and file.
Return value:
  DataFrame or TextParser
2. df_obj.head (n: int = 5) / s_obj.head (n: int = 5)
  returns the first n rows.
Parameters:
  n : int, default: 5; how many rows to return.
Return value:
  same type as caller.
3. pd.value_counts (values, sort: bool = True, ascending: bool = False, normalize: bool = False, bins = None, dropna: bool = True)
  returns a Series with unique value counts, the results are sorted in descending order, not Contains NaN value.
Parameters:
  values : data to count
  sort : bool type, whether to sort by frequency, default is True.
   ascending : bool type, ascending order, default is False.
   normalize : bool type, whether to display frequency, default is False.
   bins : int type, no longer count by value Count, but divide the interval into equal parts, and count the count in each interval.
  dropna : bool type, excluding NaN count, default is True.
Return value:
  Series.
4. df_obj / s_obj.sort_index (axis = 0, level = None, ascending = True, inplace = False, kind = "quicksort", na_position = "last", sort_remaining = True, ignore_index = False)
  Sort the sequence by index label.
Parameters:
  axis : axis to sort (0 / index: row, 1 / columns: column), default is 0.
   level : int / level name / level list / level name list; if not None, the index level Values ​​are sorted.
  ascending : Sort in ascending order, the default is True.
  inplace : If True, perform the operation in place (change the original sequence), the default is False (generate a new sorted column).
  kind: Select the sorting algorithm. (Quicksort, mergesort, heapsort), for DataFrame, only applicable when sorting a single column or label.
  na_position : last / first; NaN is placed at the beginning or end, the default is last.
  sort_remaining : The default is False, if it is True and the level or index is multi-layered, it will be sorted by other levels after sorting by the specified level.
  ingore_index : Default is False, if True, the result axis will be marked as 0,1,2, ..., n-1.

Guess you like

Origin www.cnblogs.com/pal-duan/p/12695955.html
Recommended