I have a data frame with two columns: sentence containing text and selector containing arrays of tuples of varying lengths. Consider the following data frame as an example: I now want to select the words from sentence at the position indicated by the second element in each tuple (ignoring the 10 in each tuple…
Tag: pandas
empty column in .toexcel() with pandas
i use pandas for python to generate a xlsx file with two other file. i take the first one as a template, and file the column with the second file. i wrote: but when i open my xlsx file the column ” and ‘Code du client *’ are empty, the other Columns are OK… I don’t know why it do…
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 belo…
Problem: In dataset i have data of country,state and city. Where some state and city name is 0.so,I want to replace “0” value of state with city name
I tried this method. In this code list some city of israel and generate 500 random value of it. And apply condition to insert data in israel state location where data is 0. Answer
Add missing timestamps for each different ID in dataframe
I have two dataframes (simple examples shown below): df1 shows every timestamp I am interested in. df2 shows data sorted by timestamp and ID. What I need to do is add every single timestamp from df1 that is not in df2 for each unique ID and add zero to the value column. This is the outcome I’m intereste…
Concatenate two columns excepting strings from a list_pandas
I concatenate two columns for the situation where strings from column ‘words’ are not present in the column ‘sentence’. My code is: Additionally, I want to restrict the concatenation per row if, in column ‘words’ I have strings present in this list: Here is an example of ho…
How to split a column and add additional rows from the split values in pandas?
I have a dataframe as: Here i would like to split a column middle_name using delimeter semicolon ‘;’. after splitting i would like to have a additional rows as many spitted words as existed. for example: should be Answer here is the documentation of df.explode() doc
Transformation of time series data arranged as value per column into Pandas 2D Dataframe
I have data where 13000 high frequency time-series data points are mapped as one column per point assosiated with one timestamp, when the data was measured. I read this data from an influxDB and get a Pandas.DataFrame structured as follows: I know the sampling frequency of the high frequency data (10 MHz), so…
Convert rec.array to dataframe
I’ve been trying to convert a numpy rec.array into a dataframe. The current array looks like: The result should be a five-column dataframe like the following: Weights v_1 v_2 v_3 v_4 0.2 1.76405235 0.40015721 0.97873798 2.2408932 0.2 1.86755799 -0.97727788 0.95008842 -0.15135721 …. …. ……
Python Pandas, Running Sum, based on previous rows value and grouped
I have a pandas dataframe along these lines, based on where a customer service case sits before being closed. Every time the case is edited and audit trial is captured. I want to generate a counter for each time the Department of a case changes from the department it was previously in. ID Department Start Dat…