Here are some common data wrangling commands in Pandas:
- df.head() and df.tail() to view the first and last few rows of a DataFrame, respectively.
- df.shape to see the number of rows and columns in a DataFrame.
- df.info() to get a summary of the DataFrame, including the number of non-null values in each column.
- df.describe() to get basic statistics of numeric columns in a DataFrame.
- df.columns to see the column names in a DataFrame.
- df.rename(columns={'old_name':'new_name'}) to rename columns in a DataFrame.
- df.sort_values(by='column_name') to sort a DataFrame by a specific column.
- df.groupby('column_name').mean() to group a DataFrame by a specific column and take the mean of each group.
- df.pivot_table(values='column_name', index='grouping_column', columns='aggregating_column') to create a pivot table.
- df.apply(function) to apply a function to each element in a DataFrame.
- df.dropna() to drop rows with missing values.
- df.fillna(value) to fill missing values with a specific value.
No comments:
Post a Comment