Categories
Development Linux Ubuntu

Finding which elements in a vector have an edit distance of one and the same length?

I have a dataframe, an example is shown below, that has a list of words (Word), the number of sounds in those words (NumSounds), and the transcription of the sounds in each word (Pronunciation). I have been trying to create a file that shows me what the minimal pairs are for each word in the […]

Categories
Development

How do I represent time as an int in a pandas DataFrame?

I have a DataFrame, read in from a CSV, as such (times as HH:MM:SS): pta ptd tpl_num 4 05:17 05:18 0 6 05:29:30 05:30 1 9 05:42 05:44:30 2 11 05:53 05:54 3 12 06:03 06:05:30 4 17 06:24:30 NaN 5 dtypes: pta object ptd object tpl_num int64 I’m trying to get the pta and […]

Categories
Development

Pandas – Duplicate rows on function application

I have a dataframe, and I’m trying to apply a single function to that dataframe, with multiple arguments. I want the results of the function application to be stored in a new column, with each row duplicated to match each column, but I can’t figure out how to do this. Simple example: df= pd.DataFrame({“a” : […]

Categories
Development

Pandas: occurrence matrix from one hot encoding from pandas dataframe

I have a dataframe, it’s in one hot format: dummy_data = {‘a’: [0,0,1,0],’b’: [1,1,1,0], ‘c’: [0,1,0,1],’d’: [1,1,1,0]} data = pd.DataFrame(dummy_data) Output: a b c d 0 0 1 0 1 1 0 1 1 1 2 1 1 0 1 3 0 0 1 0 I am trying to get the occurrence matrix from dataframe, […]

Categories
Development

Count and Group By – Pandas Dataframe

I have a dataframe, csv_table that looks like this: | time | ID | range | text | |:—–:|:—————-:|:—–:|:————————————————–:| | 90000 | B0A0F80A06A3AB6C | 0 | In what year did baseball become an offical sport? | | 90000 | 95A33E619934A39B | 0 | wirehair pointing griffon | | 90000 | E613C21C535BC636 | 30 | ncic […]

Categories
Development

Detect whether cells of a column are identical to the corresponding rows of other columns

For example, I have a dataframe, I want to know whether the cells in column “x” is identical to the corresponding rows of other columns. mydf <- data.frame( x = paste(letters[1:5]), y_1 = c(“a”,”f”,”g”,”h”,”k”), y_2 = c(“z”,”x”,”l”,”q”,”n”), y_3 = c(“q”,”f”,”d”,”c”,”e”) ) I want the result looks like this: x y_1 y_2 y_3 result a a […]

Categories
Development

R: when using Mutate by subtracting 2 varying columns and 2 static object the new columns is static, which is wrong

So, I have a dataframe, I’m currently trying to use mutate to come up with new columns from current columns, already created new columns, and a few static object. Data Sample: ##All mydf<- as.data.frame(matrix(c(1,1,1,1,1,2,2,2,2,2,0,1,2,3,4,0,1,2,3,4,100,90,40,30,0,100,80,50,10,0), nrow=10, ncol=3)) colnames <- c(“path”,”month”, “Notional”) mydf<-setNames(mydf,colnames) print(mydf) > print(mydf) path month Notional 1 1 0 100 2 1 1 90 […]

Categories
Development

Why does Periodgram R function error for my dataframe?

I have a dataframe, which is fine to use as a time series using hts package (uses forecast) for ARIMA predictions. I am trying to use xreg with Fourier components. But there is something wrong, because I cannot even get a Periodogram with my dataframe,: it says the x and y lengths differ. while I […]