Skip to content
Advertisement

Tag: dataframe

Convert 2D dataframe to 3D numpy array based on unique ID

I have a dataframe in this format: … though my dataframe is much larger, with more than 500 hundred IDs. I want to convert this 2D – dataframe into a 3D array in this format (num_time_samples, value, ID). Essentially I would like to have one 2D-array for every unique ID. I plan on using the value column to build lag

Create pandas dataframe on column name conditions

Python newbie attempting a complex pandas dataframe logic I have multiple dataframes I need to join but I’ll show two below for the example. The dataframe have duplicate columns labelled with suffix ‘_duplicate’. I need to replicate the row instead of having the duplicate column as seen below. My first thought is to get a list of unique column names

Use list items as column seperators pd.read_fwf

I have text files containing tables which I want to put into a dataframe. Per file the column headers are the same, but the width is different depending on the content (because they contain names of different lengths for example). So far I managed to get the index of the first character of the header, so I know where the

How to join sentences inside data frame column?

I have create a sample data frame and it contains a column Called ‘Body’ and the content of it as below. ‘[‘Former India captains should have shown the maturity to sort out the matter privately’, ‘When egos clash, the results are often disastrous. Ugly too. And the row tends to rumble on. That’s what has happened in the Virat Kohli-Sourav

Pandas Aggregate Daily Data to Monthly Timeseries

I have a time series that looks like this (below) And I want to resample it monthly, so it has 2019-10 is equal to the average of all the values of october, November is the average of all the PTS values for November, etc. However, when i use the pd.resample(‘M’).mean() method, if the final day for each month does not

Advertisement