0% found this document useful (0 votes)
2 views2 pages

Pandas Basic Functions

The document provides a comprehensive list of basic and commonly used functions in the Pandas library, including creating DataFrames, reading and writing data, data inspection, and data manipulation. It covers essential operations such as data cleaning, aggregation, date and time functions, pivoting, reshaping, and basic visualization. This serves as a useful reference for performing various tasks when working with Pandas.

Uploaded by

ah.jubair110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Pandas Basic Functions

The document provides a comprehensive list of basic and commonly used functions in the Pandas library, including creating DataFrames, reading and writing data, data inspection, and data manipulation. It covers essential operations such as data cleaning, aggregation, date and time functions, pivoting, reshaping, and basic visualization. This serves as a useful reference for performing various tasks when working with Pandas.

Uploaded by

ah.jubair110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Certainly!

Here is a list of some basic and commonly used functions in the Pandas library:

1. **Creating DataFrames:**
- `pd.DataFrame(data)`: Create a DataFrame from a dictionary,
list, or another DataFrame.

2. **Reading and Writing Data:**


- `pd.read_csv('file.csv')`: Read a CSV file into a DataFrame.
- `df.to_csv('file.csv')`: Write a DataFrame to a CSV file.
- `pd.read_excel('file.xlsx')`: Read an Excel file into a DataFrame.
- `df.to_excel('file.xlsx')`: Write a DataFrame to an Excel file.
- `pd.read_json('file.json')`: Read a JSON file into a DataFrame.
- `df.to_json('file.json')`: Write a DataFrame to a JSON file.

3. **Data Inspection:**
- `df.head(n)`: Return the first `n` rows of the DataFrame.
- `df.tail(n)`: Return the last `n` rows of the DataFrame.
- `df.info()`: Print a concise summary of the DataFrame.
- `df.describe()`: Generate descriptive statistics.

4. **Indexing and Selecting Data:**


- `df['column_name']`: Select a single column.
- `df[['col1', 'col2']]`: Select multiple columns.
- `df.loc[row_indexer, column_indexer]`: Access a group of rows
and columns by labels.
- `df.iloc[row_indexer, column_indexer]`: Access a group of rows
and columns by integer position.

5. **Data Cleaning:**
- `df.dropna()`: Remove missing values.
- `df.fillna(value)`: Fill missing values with a specified value.
- `df.drop(columns=['col1', 'col2'])`: Drop specified columns.
- `df.rename(columns={'old_name': 'new_name'})`: Rename
columns.
6. **Data Manipulation:**
- `df.sort_values(by='column_name')`: Sort the DataFrame by a
specified column.
- `df.groupby('column_name')`: Group the DataFrame using a
column.
- `df.merge(other_df, on='key')`: Merge DataFrames on a key
column.
- `df.concat([df1, df2])`: Concatenate DataFrames.

7. **Aggregation and Transformation:**


- `df.mean()`: Calculate the mean of each column.
- `df.sum()`: Calculate the sum of each column.
- `df.min()`: Calculate the minimum value of each column.
- `df.max()`: Calculate the maximum value of each column.
- `df.apply(func)`: Apply a function along an axis of the
DataFrame.

8. **Date and Time Functions:**


- `pd.to_datetime(df['date_column'])`: Convert a column to
datetime.
- `df['date_column'].dt.year`: Extract the year from a datetime
column.
- `df['date_column'].dt.month`: Extract the month from a datetime
column.

9. **Pivoting and Reshaping:**


- `df.pivot(index='col1', columns='col2', values='col3')`: Pivot a
DataFrame.
- `df.melt(id_vars=['col1'], value_vars=['col2', 'col3'])`: Unpivot a
DataFrame.

10. **Visualization:**
- `df.plot()`: Basic plotting of DataFrame columns.

These functions should cover a wide range of basic operations you might need when
working with Pandas.

You might also like