indexing

php submit only giving last value from array that populates form

拟墨画扇 提交于 2021-02-17 05:54:45
问题 Struggling with a one page form that i want to first populate a form from a mysql query, then enable a user to update some of the values in each of several table rows from text input fields in the form. The code's intent is to update the field by referencing the row ID. But for some reason I'm only able to update the last row in the form (the last row from the array). I've included some troubleshooting code to see what the ID variable is and it always comes up as the last iteration of the

Select columns of table index

强颜欢笑 提交于 2021-02-17 05:41:05
问题 Oracle has a query that selects the existing indexes of a table. For example: SELECT * FROM user_indexes WHERE table_name = 'CM_WCEL'; But I need to recreate the index creation statement. How can I get the remaining information like the affected columns, etc? 回答1: To get the complete DDL for each index, use dbms_metadata.get_ddl() : select index_name, dbms_metadata.get_ddl('INDEX', index_name) as ddl from user_indexes where table_name = CM_WCEL'; The DDL is returned as a CLOB. Depending on

Implicit transposing in numpy array indexing

天涯浪子 提交于 2021-02-16 18:33:31
问题 I came across a weird problem: from numpy import zeros, arange aa = zeros([1, 3, 10]) aa[0, :, arange(5)].shape Running this gives me (5,3) , but I'm expecting (3,5) . However, running the following gives me (3,5) as expected. aa = zeros([3, 10]) aa[:, arange(5)] This is easy to fix as part of my program, but it completely ruined my belief. I tried to search for similar questions that have already been answered but have no idea what to search for. Thank you and Happy Chinese New Year! 回答1:

Extract value of a particular column name in pandas as listed in another column

谁说胖子不能爱 提交于 2021-02-16 15:09:30
问题 The title wasn't too clear but here's an example. Suppose I have: person apple orange type Alice 11 23 apple Bob 14 20 orange and I want to get this column person new_col Alice 11 Bob 20 so we get the column 'apple' for row 'Alice' and 'orange' for row 'Bob'. I'm thinking iterrows, but that would be slow. Are there faster ways to do this? 回答1: Use DataFrame.lookup: df['new_col'] = df.lookup(df.index, df['type']) print (df) person apple orange type new_col 0 Alice 11 23 apple 11 1 Bob 14 20

Extract value of a particular column name in pandas as listed in another column

久未见 提交于 2021-02-16 15:09:28
问题 The title wasn't too clear but here's an example. Suppose I have: person apple orange type Alice 11 23 apple Bob 14 20 orange and I want to get this column person new_col Alice 11 Bob 20 so we get the column 'apple' for row 'Alice' and 'orange' for row 'Bob'. I'm thinking iterrows, but that would be slow. Are there faster ways to do this? 回答1: Use DataFrame.lookup: df['new_col'] = df.lookup(df.index, df['type']) print (df) person apple orange type new_col 0 Alice 11 23 apple 11 1 Bob 14 20

Getting index name for the max value in DF [duplicate]

↘锁芯ラ 提交于 2021-02-16 15:09:26
问题 This question already has answers here : Pandas max value index (3 answers) Closed 2 years ago . I have the following dataframe: data = {'Algorithm': ['KNN', 'Decision Tree', 'SVM', 'Logistic Regression'], 'Jaccard': [0.75,0.65,0.67,0.70], 'F1-score': [0.69,0.78, 0.75, 0.77], 'LogLoss': ['NA', 'NA', 'NA', 5.23]} report= pd.DataFrame(data = data) report = report[['Algorithm', 'Jaccard', 'F1-score', 'LogLoss']] report.set_index(report['Algorithm'], inplace = True) report.drop(columns = [

Extract value of a particular column name in pandas as listed in another column

人盡茶涼 提交于 2021-02-16 15:08:57
问题 The title wasn't too clear but here's an example. Suppose I have: person apple orange type Alice 11 23 apple Bob 14 20 orange and I want to get this column person new_col Alice 11 Bob 20 so we get the column 'apple' for row 'Alice' and 'orange' for row 'Bob'. I'm thinking iterrows, but that would be slow. Are there faster ways to do this? 回答1: Use DataFrame.lookup: df['new_col'] = df.lookup(df.index, df['type']) print (df) person apple orange type new_col 0 Alice 11 23 apple 11 1 Bob 14 20

Extract value of a particular column name in pandas as listed in another column

て烟熏妆下的殇ゞ 提交于 2021-02-16 15:08:22
问题 The title wasn't too clear but here's an example. Suppose I have: person apple orange type Alice 11 23 apple Bob 14 20 orange and I want to get this column person new_col Alice 11 Bob 20 so we get the column 'apple' for row 'Alice' and 'orange' for row 'Bob'. I'm thinking iterrows, but that would be slow. Are there faster ways to do this? 回答1: Use DataFrame.lookup: df['new_col'] = df.lookup(df.index, df['type']) print (df) person apple orange type new_col 0 Alice 11 23 apple 11 1 Bob 14 20

Mysql index on view not working

六眼飞鱼酱① 提交于 2021-02-16 13:28:09
问题 I created a view named 'myview' as below. create view myview as select 'a' source,col1,col2 from table_a union select source,col1,col2 from table_b ; table_a has an index on col1 , table_b has an index on source , col1 . When I query on myview as below, no index is used. select * from myview where source = a and col1 = 'xxx' ; How do I make the indexes work on this query? Create Code CREATE TABLE `table_a` ( `col1` VARCHAR(50) NULL DEFAULT NULL, `col2` VARCHAR(50) NULL DEFAULT NULL, INDEX

Snakemake: confusion on how to access config files properly

拜拜、爱过 提交于 2021-02-15 11:53:52
问题 This question follows on from a question I asked previously and it regards understanding how to access config files correctly using Snakemake. I have a specific problem I need to address which I'll ask first and a general problem understanding how indexing works which I'll ask second. I'm using snakemake to run and ATAC-seq pipeline from Alignment/QC through to motif analysis. A: Specific Question I'm trying to add a rule called trim_galore_pe to trim adapters from my fastq files before