Skip to content

Tag: pandas

Closing figures from previous sessions

I am running a python code that produces some figures with Matplotlib and Pandas. After a few runs of the code, I am getting to following error: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed a…

calculate sum of squares with rows above

I have a dataset that looks like this: I want to iterate through each row and calculate a sum of squares value for each row above (only if the Type matches). I want to put this value in the X.sq column. So for example, in the first row, there’s nothing above. So only (-1.975767 x -1.975767). In the seco…

Creating Dataframes for different clusters

I have a dataset Using this dataset, I clustered the dataset based on the number of times “System” is repeated for a particular “Name”. In the above example, Names A, B and D have one “AZ” “Subset” while C, E have two “AY” subsets and F has two AZ so…

CET timezone strings to datetime

I have a data frame that has columns looking similar to this. This data is imported from SQL into a Pandas data frame, and when I print out the dtypes I can see that the date_cet column is object. Since I need it further on, I want to convert it to a datetime object. However, the stuff I’ve tried just

Pandas combine rows in groups to get rid of Nans

I want to do something similar to what pd.combine_first() does, but as a row-wise operation performed on a shared index. And to also add a new column in place of the old ones – while keeping the original_values of shared column names. In this case the ‘ts’ column is one that I want to replac…