read_csv()
to read the CSV file: df = pd.read_csv("data.csv")
df = df.dropna()
df["column_name"].fillna(value)
df["column_name"] = df["column_name"].astype(dtype)
df.sort_values(by="column_name")
groupby_object = df.groupby(by="column_name")
2. Data analysis
describe()
: View basic statistics of datamean()
: Calculate the average valuestd()
: Calculate standard deviationplot()
: Generate various chart types, such as line charts and scatter chartsbar()
:Generate bar chartpie()
:Generate pie chartagg()
: Apply aggregate function on grouped datapivot_table()
: Create a crosstab for summarizing and analyzing data3. Data operation
loc[index_values]
: Get data by index valueiloc[index_values]
: Get data by index positionquery()
: Filter data by conditionsappend()
:Append data to DataFramemerge()
: Merge two or more DataFramesconcat()
: Concatenate multiple DataFrames togetherapply()
:Apply the function row by row or column by columnlambda()
: Create an anonymous function to transform data4. Advanced skills
str.strip()
: Remove whitespace characters from stringstr.replace()
: Replace characters in the string or regular expression
str.lower()
: Convert the string to lowercase5. Case application
The above is the detailed content of Python Pandas practical drill, a quick advancement for data processing novices!. For more information, please follow other related articles on the PHP Chinese website!