Skip to content
Advertisement

Tag: pandas

how to eliminate duplicate rows in column A keeping the maximum value in B in python

I’m working with data from an excel file like this. I’m using this line of code to eliminate the duplicates keeping the maximum df_clean=df_raw.sort_values(‘A’, ascending=False).drop_duplicates(‘B’).sort_index() but I’m obtaining this error Index([‘B’], dtype=’object’) I don’t know which could be the problem since I’m doing it after the upload of the file. Answer If I can assume that your index is just

Slice pandas row of a specific column using numpy boolean

The objective is to slice multiple pandas row of a specific column using a Numpy boolean. The following code should do the task However, I wonder whether the above code can be shortened further, especially these lines Currently, Pandas throw an error if I am to directly using Numpy boolean without converting to list Is there something I miss, or

Plot Between Certain Y axis Values

I’m plotting some values using Pandas. But my Values are soo close together It doesn’t actually show anything. Is there a way to restrict Y-axis to “Zoom in” on the differences? And then really show the difference between the value even though there isn’t much..? Answer You can adjust the y-axis start and end by replacing the last line bplot.plot.bar(

Advertisement