I have a data frame with below columns, using which need to create new columns by grouping Name. Status should be updated as active to entire group if it is active for any one St. data = {‘Name’:[‘Tom’, ‘Tom’, ‘krish’, ‘jack’,’jack’,’Nam’,’sue’], ‘St’:[‘S-123’, ‘S-290’, ‘S-123’, ‘S-147′,’S-98′,’S-123′,’S-38’], ‘Status’:[‘Inactive’,’active’,’active’,’inactive’,’active’,’Inactive’,’Inactive’]} df = pd.DataFrame(data) The desired output is Name St […]
Tag: “Sue”
I am trying to solve the following problem using Python: Given the following student list: students = [‘Tom’, ‘Kitty’, ‘Jessie’, ‘Chester’, ‘Curie’, ‘Darwing’, ‘Nancy’, ‘Sue’, ‘Peter’, ‘Andrew’, ‘Karren’, ‘Charles’, ‘Nikhil’, ‘Justin’, ‘Astha’] I need to assign the students into 3 groups. The group identity of each student is specified by the integer at the same […]
Rewind with RFD – Show 610
What kind of exercise can you do in 1 minute, 17 seconds? Maybe 60 crunches or even 60 pushups if you’re pretty fit. But how about… climbing multiple flights of stairs, hoisting a 42-pound hose, descending those stairs (making sure you touch every single one), driving a 160-pound steel beam back five feet, running a […]
If I have a table: talker | listener | minutes ——–+———-+——— sue | rob | 3 sue | jan | 2 jan | sue | 1 rob | sue | 7 jan | sue | 4 rob | sue | 6 rob | jan | 5 dan | jan | 5 sue | abe | […]
I have a dataframe with missing values for some columns: a = pd.DataFrame(data = {"name":[‘bob’,’sue’,’dave’],’status’:[np.NaN,np.NaN,’A’],’team’:[‘red’,’blue’,np.NaN]},index=[100,101,105]) Dataframe a I have another dataframe with the same index where some of the missing values have been replaced: b = pd.DataFrame(data = {"name":[‘bob’,’sue’,’dave’],’status’:[‘I’,’O’,’A’],’team’:[‘red’,’blue’,np.NaN]},index=[100,101,105]) Dataframe b Is there a way to map dataframe "b" to "a" so that the values […]
I am trying to merge to Pandas DataFrame as below: import numpy as np import pandas as pd df = pd.DataFrame({“vals”: np.random.RandomState(31).randint(-30, 30, size=15), “grps”: np.random.RandomState(31).choice([“A”, “B”], 15)}) mean = df.groupby(‘grps’).mean().rename(columns={‘vals’:’mean’}) df.merge(df, mean, left_on=’grps’, right_index=True) But I got this error: … /opt/conda/lib/python3.7/site-packages/pandas/core/reshape/merge.py in _maybe_coerce_merge_keys(self) 1144 inferred_right in string_types and inferred_left not in string_types 1145 ): […]
I have test data for Students and the marks they have attained. How do i write a function called nameList, that will make a list of just the names of students? import Data.Char type StudentMark = (String, Int) testData :: [StudentMark] testData = [(“John”, 53), (“Sam”, 16), (“Kate”, 85), (“Jill”, 65), (“Bill”, 37), (“Amy”, 22), […]
I have a CSV file each line formatted as: 20 char string, 10 char string, 4 char string, and a double. The goal is to read the file and store the information into a list collection. then sort using a comparator on the 3rd column and then the 1st column. What I’d like to know […]
How would you punctuate the sentence below? Is it okay the way it is? I’ve never seen a sentence that introduced more than one list with a colon. I considered just taking out the colons. I also considered replacing them with commas. I haven’t been able to find a clear answer in my research. Here […]
I’m trying to use purr to summarize a particular column of a nested list column. library(tidyverse) z <- tibble(name = c(“Bill”,”Bill”,”Bill”,”Sue”,”Sue”), grade =c(90L,95L,70L,100L,98L), time=c(10L,11L,10L,15L,16L)) summary <- z %>% group_by(name) %>% nest %>% mutate(n = map_int(data,nrow)) %>% mutate(avg = map(data$grade,mean)) %>% mutate(ttl_time = map(data$time, sum)) When I run this I get an error:: Column y must […]