📅  最后修改于: 2023-12-03 14:48:01.525000             🧑  作者: Mango
tqdm.pandas
is a Python package that adds progress bars to pandas apply progressions. It has a simple and easy-to-use interface that allows you to monitor the progress of a long-running process in real-time.
The tqdm.pandas
package can be installed using pip as follows:
pip install tqdm pandas
To use tqdm.pandas
, simply import the package and call the progress_apply
function on your pandas DataFrame:
from tqdm import tqdm
import pandas as pd
df = pd.read_csv('data.csv')
tqdm.pandas()
df['new_col'] = df['old_col'].progress_apply(lambda x: x + 1)
This will add a progress bar to the apply
function call, allowing you to see the progress of the operation:
100%|██████████| 10000/10000 [00:12<00:00, 794.13it/s]
You can also use progress_map
function for pd.Series
:
from tqdm import tqdm
import pandas as pd
s = pd.read_csv('data.csv', squeeze=True)
tqdm.pandas()
new_s = s.progress_map(lambda x: x + 1)
This will add a progress bar to the map
function call.
tqdm.pandas
is a simple yet powerful package that adds progress bars to pandas apply progressions. It is easy to use and provides valuable feedback on long-running processes.