Skip to content
Advertisement

Tag: dataframe

Empty dataframe when filtering

I have a dataframe that looks like this: Now I’d like to filter like this: However, I am getting an empty dataframe. What am I doing wrong here? Answer Try df1.loc[df1[‘PZAE’]==”‘HAE'”] Details : the column ‘PZAE’ contains str starting and finishing by ‘ that’s why you have to include them in the condition

Use DataFrame column as index and append duplicates as new columns

I have a DataFrame that contains a column with dates which I’d like to use as my DataFrame’s index. The dates in that column are not necessarily unique – sometimes there might be duplicates. I wish to append duplicates as new columns. Dates that are unique can just contain NaN (or whatever) for the newly appended columns. To clarify I’ll

Python: Create lists from diagonal values in a dataframe

I’m trying to create a routine in Python to collect every diagonal group of values in df. Here’s a reproducible example of what I’m trying to achieve: This code returns me one single list: And based on the structure of the given df, what I’m trying to achieve is: From what I’ve seen I could do this by creating a

Advertisement