Skip to content

Tag: pandas

Python Pandas: How to get previous dates with a condition [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I have dataset with the following columns: encounterDate FormName PersonID…

Pandas split group into first and last values

I have multiple dataframes with a structure that starts with 10 and then goes from 0 to 10: So far I’ve been using this code to group the dataframe by type: It works fine for types 0-9, but I’d also like to split type 10 into 2 groups to distinguish first and last values instead of having it all i…

Converting datetime only to time in pandas

I would like to ask a question regarding converting datetime only to time. I have values ‘Date Created” that include Dates and Times in one column and I would like to create two columns: one with only Date and one with Time. I wrote a code but in Time column I got a default date of 1900-01-01 alon…

Using pct_change on grouped multiindex dataframe with a datestamp

I have a following dataframe df: And I want to know percentage change of users per datestamp device country columns. I tried: But it ignores the grouping and checks it simply row by row. Desired result would look like this: Answer It looks like you want the percent change for each device / country combination…

Transposing and Creating Flat files Using Pandas

I have the following table For each top level 3, there are sub levels 4,5,6, etc. For some level 3, there are no sub-level. I need to transpose levels and create a meaningful flat file like this using pandas. Answer I’ll probably be lynched for this but since there isn’t any better answer – hope that he…