Package: a-pandas-ex-drop-duplicates-without-pain
Installationpipinstalla-pandas-ex-drop-duplicates-without-painUsagefroma_pandas_ex_drop_duplicates_without_painimportpd_add_drop_duplicates_without_painpd_add_drop_duplicates_without_pain()importpandasaspddf=pd.read_csv("https://github.com/pandas-dev/pandas/raw/main/doc/data/air_quality_long.csv")print(f'{df=}')df_with_duplicates=df[['city','country','location','parameter','value','unit']].copy()print(f'{df_with_duplicates=}')df_without_duplicates=df_with_duplicates[['city','country','location','parameter','value','unit']].drop_duplicates().copy()print(f'{df_without_duplicates=}')df_with_duplicates['provoke_error']=[[[1]*10]]*len(df_with_duplicates)print(f'{df_with_duplicates=}')df_result1=Nonedf_result2=Nonetry:df_result1=df_with_duplicates.drop_duplicates()exceptExceptionasErr:print(Err)df_result2=df_with_duplicates.ds_drop_duplicates_without_pain()print(f'{df_result1=}')print(f'{df_result2=}')df.parameter.ds_drop_duplicates_without_pain()df=citycountrydate.utc...parametervalueunit0AntwerpenBE2019-06-1806:00:00+00:00...pm2518.0µg/m³1AntwerpenBE2019-06-1708:00:00+00:00...pm256.5µg/m³2AntwerpenBE2019-06-1707:00:00+00:00...pm2518.5µg/m³3AntwerpenBE2019-06-1706:00:00+00:00...pm2516.0µg/m³4AntwerpenBE2019-06-1705:00:00+00:00...pm257.5µg/m³.....................5267LondonGB2019-04-0906:00:00+00:00...no241.0µg/m³5268LondonGB2019-04-0905:00:00+00:00...no241.0µg/m³5269LondonGB2019-04-0904:00:00+00:00...no241.0µg/m³5270LondonGB2019-04-0903:00:00+00:00...no267.0µg/m³5271LondonGB2019-04-0902:00:00+00:00...no267.0µg/m³[5272rowsx7columns]df_with_duplicates=citycountrylocationparametervalueunit0AntwerpenBEBETR801pm2518.0µg/m³1AntwerpenBEBETR801pm256.5µg/m³2AntwerpenBEBETR801pm2518.5µg/m³3AntwerpenBEBETR801pm2516.0µg/m³4AntwerpenBEBETR801pm257.5µg/m³..................5267LondonGBLondonWestminsterno241.0µg/m³5268LondonGBLondonWestminsterno241.0µg/m³5269LondonGBLondonWestminsterno241.0µg/m³5270LondonGBLondonWestminsterno267.0µg/m³5271LondonGBLondonWestminsterno267.0µg/m³[5272rowsx6columns]df_without_duplicates=citycountrylocationparametervalueunit0AntwerpenBEBETR801pm2518.0µg/m³1AntwerpenBEBETR801pm256.5µg/m³2AntwerpenBEBETR801pm2518.5µg/m³3AntwerpenBEBETR801pm2516.0µg/m³4AntwerpenBEBETR801pm257.5µg/m³..................5087LondonGBLondonWestminsterno281.0µg/m³5090LondonGBLondonWestminsterno283.0µg/m³5091LondonGBLondonWestminsterno276.0µg/m³5092LondonGBLondonWestminsterno270.0µg/m³5098LondonGBLondonWestminsterno279.0µg/m³[819rowsx6columns]df_with_duplicates=citycountry...unitprovoke_error0AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]1AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]2AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]3AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]4AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]...............5267LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5268LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5269LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5270LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5271LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]][5272rowsx7columns]unhashabletype:'list'df_result1=Nonedf_result2=citycountry...unitprovoke_error0AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]1AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]2AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]3AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]4AntwerpenBE...µg/m³[[1,1,1,1,1,1,1,1,1,1]]...............5087LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5090LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5091LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5092LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]]5098LondonGB...µg/m³[[1,1,1,1,1,1,1,1,1,1]][819rowsx7columns]Out[2]:0pm251825no2Name:parameter,dtype:object