Skip to content

Tag: pandas

Remove leading zeroes pandas

For example I have such a data frame And I need to remove all leading zeroes and replace NONEs with zeros: I did it with cycles but for large frames it works not fast enough. I’d like to rewrite it using vectores Answer you can try str.replace

Simple example of Pandas ExtensionArray

It seems to me that Pandas ExtensionArrays would be one of the cases where a simple example to get one started would really help. However, I have not found a simple enough example anywhere. Creating an ExtensionArray To create an ExtensionArray, you need to Create an ExtensionDtype and register it Create an E…

combine pd.loc and pd.iloc to assign value

My input: I try assign new value based on other column in this way it work: dd.loc[dd.iloc[:,1]==0,[‘result_’+cv_detail[0]] ] = ‘Other’ OR dd.loc[dd.sum_result_ICV == 0, “result_ICV”] = ‘Other’ But this code doesn’t, code make more columns, with assign new…

Adding date to pd.to_datetime

I’m looking for a way to add custom date to pd.to_datetime. So, for example: Print: pd.to_datetime keeps adding today’s date which is fine in case of csv_file but csv_file2 need to contain tomorrow’s date. Here’s sample of csv files: Answer Idea is create helper column file for disting…

How to read 24:00 hour?

I have a csv file with 24:00 hour instead of 00:00 and try to read it with pandas. I found solution and try to adopt it. The problem is, I get an error and don’t know how to fix it. Can someone help me? My csv: The code I got from the link above adopted to my case: The error