I have been banging my head against a wall for a while now trying to figure out this seemingly easy data manipulation task in Pandas, however I have had no success figuring out how to do it or googling a sufficient answer :( All I want to do is take the table on the left of the snip below (will
Tag: data-manipulation
How to format query results as CSV?
My goal: Automate the operation of executing a query and output the results into a csv. I have been successful in obtaining the query results using Python (this is my first project ever in Python). I am trying to format these results as a csv but am completely lost. It’s basically just creating 2 massive rows with all the data
Convert multiple binary columns into crosstab
I am trying to convert the following dataset which has multiple binary variables into a crosstab. into the following crosstab but i am having no luck emotion blue green red happy 2 2 2 angry 1 2 1 sad 1 1 0 Answer This is matix multiplication: Output:
Advanced string manipulation in Python
I’m trying to get only the value that are after the string 2021 from the following string: I need to get those 2 values separated (first one has to be 168088000000 and the second one has to be 61271000000 in this case). They have to be preceded by 2021 (and the result should give only the 2 numbers I mentioned
Pandas Selection of rows not working propelry
I am trying to delete rows of a df which are not part of an other columns entry from another table. For further explanation: I have a table with transactions including materialnumbers and another table with production information also including materialnumbers. I want to delete every row where a materialnumber is contained which is not in the other table. My
How can I use value_counts() only for certain values?
I want to extract how many positive reviews by brand are in a dataset which includes reviews from thousands of products. I used this code and I got a table including percentaje of positive and non-positive reviews. How can I get only the percentage of positive reviews by brand? I only want the “True” results in positive_review. Thanks! Answer You
How to split data in a column into some separate columns in Python?
So, I have a data frame given below: I want to have the results in the og dataframe with some single line strings separately, such as [107.625764, -6.910353], [107.625871, -6.910358], split to 107.625764, -6.910353 . The detail of expected results are in the picture below. Expected Results All I know that we can apply str.split method with specifying any specific
insert column into array using scaler obj (numpy.insert)
why C4 did not take column value and insert it before each item in column 1 i think it should be [[ 1 9 6][ 2 99 7][ 3 999 8]] also why the result is equal to not equal to while the insert axis along axis 0 will inserted normally the result: Answer after searching we found the answer