rowname

Remove index name in pandas

家住魔仙堡 提交于 2019-11-27 07:32:10
I have a dataframe like this one: In [10]: df Out[10]: Column 1 foo Apples 1 Oranges 2 Puppies 3 Ducks 4 How to remove index name foo from that dataframe? The desired output is like this: In [10]: df Out[10]: Column 1 Apples 1 Oranges 2 Puppies 3 Ducks 4 Use del df.index.name In [16]: df Out[16]: Column 1 foo Apples 1 Oranges 2 Puppies 3 Ducks 4 In [17]: del df.index.name In [18]: df Out[18]: Column 1 Apples 1 Oranges 2 Puppies 3 Ducks 4 Alternatively you can just assign None to the index.name attribute: In [125]: df.index.name = None df Out[125]: Column 1 Apples 1 Oranges 2 Puppies 3 Ducks 4

Convert row names in multiple data frames to column in data frame

☆樱花仙子☆ 提交于 2019-11-27 05:57:29
问题 I have a list of .csv files that I have read in to R and placed in a large data frame called data that consists of 6 data.frames which are the 6 files in filenames . My code so far is: filenames <- list.files( paste(mainDirInput,sep=""), pattern="Out.*csv", full.names=TRUE) data = lapply(filenames, function(f) { wb = read.csv(f, header=TRUE) }) The row names and column names in each data.frame are exactly the same, I would like to extract the row names and instead have them as the first

Merging more than 2 dataframes in R by rownames

人盡茶涼 提交于 2019-11-27 04:16:30
问题 I gather data from 4 df's and would like to merge them by rownames. I am looking for an efficient way to do this. This is a simplified version of the data I have. df1 <- data.frame(N= sample(seq(9, 27, 0.5), 40, replace= T), P= sample(seq(0.3, 4, 0.1), 40, replace= T), C= sample(seq(400, 500, 1), 40, replace= T)) df2 <- data.frame(origin= sample(c("A", "B", "C", "D", "E"), 40, replace= T), foo1= sample(c(T, F), 40, replace= T), X= sample(seq(145600, 148300, 100), 40, replace= T), Y= sample

Removing display of row names from data frame

a 夏天 提交于 2019-11-27 03:53:14
I am creating a dataframe using this code: df <- data.frame(dbGetQuery(con, paste('select * from test'))) Which results in this: UID BuildingCode AccessTime 1 123456 BUILD-1 2014-06-16 07:00:00 2 364952 BUILD-2 2014-06-15 08:00:00 3 95865 BUILD-1 2014-06-06 09:50:00 I am then trying to remove the row names (1, 2, 3, etc) as suggested here by using this code: rownames(df) <- NULL But then when I print out df it still displays the row names. Is there a way to not include the row names when creating the data frame? I found a suggestion about row.name = FALSE but when I tried it I just got errors

Merge many data frames from csv files, when ID column is implied?

强颜欢笑 提交于 2019-11-27 01:44:14
I'd like to merge a bunch of data frames together (because it seems many operations are easier if you're only dealing w/ one, but correct me if I'm wrong). Currently I have one data frame like this: ID, var1, var2 A, 2, 2 B, 4, 5 . . Z, 3, 2 Each ID is on a single row w/ several single measurements I also have a csv file w/ repeated measurement for each ID, like: filename = ID_B.csv time, var4, var5 0, 1, 2 1, 4, 5 2, 1, 6 ... What I'd like is: ID, time, va1, var2, var4, var5 ... B, 0, 4, 5, 1, 2, B, 1, 4, 5, 4, 5, B, 2, 4, 5, 1, 6, ... I don't really care about the column order. The only

How to remove rows of a matrix by row name, rather than numerical index?

妖精的绣舞 提交于 2019-11-27 01:15:33
问题 I have matrix g : > g[1:5,1:5] rs7510853 rs10154488 rs12159982 rs2844887 rs2844888 NA06985 "CC" "CC" "CC" "CC" "CC" NA06991 "CC" "CC" "CC" "CC" "CC" NA06993 "CC" "CC" "CC" "CC" "CC" NA06994 "CC" "CC" "CC" "CC" "CC" NA07000 "CC" "CC" "CC" "CC" "CC" > rownames(g)[1:2]->remove > remove [1] "NA06985" "NA06991" > g[-remove,] Error in -remove : invalid argument to unary operator Is there a simple way to do what I want to do here (remove the ID's referenced in the vector 'remove' from matrix g ?

Merge many data frames from csv files, when ID column is implied?

百般思念 提交于 2019-11-26 17:28:30
问题 I'd like to merge a bunch of data frames together (because it seems many operations are easier if you're only dealing w/ one, but correct me if I'm wrong). Currently I have one data frame like this: ID, var1, var2 A, 2, 2 B, 4, 5 . . Z, 3, 2 Each ID is on a single row w/ several single measurements I also have a csv file w/ repeated measurement for each ID, like: filename = ID_B.csv time, var4, var5 0, 1, 2 1, 4, 5 2, 1, 6 ... What I'd like is: ID, time, va1, var2, var4, var5 ... B, 0, 4, 5,

What is about the first column in R&#39;s dataset mtcars?

心已入冬 提交于 2019-11-26 11:30:36
问题 I think I am missing a fundamental concept about R\'s data frames. head(mtcars) mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 The names of the cars here. Is this a column? I don\'t

Convert row names into first column

♀尐吖头ヾ 提交于 2019-11-26 11:14:11
I have a data frame like this: df VALUE ABS_CALL DETECTION P-VALUE 1007_s_at "957.729231881542" "P" "0.00486279317241156" 1053_at "320.632701283368" "P" "0.0313356324173416" 117_at "429.842323161046" "P" "0.0170004527476119" 121_at "2395.7364289242" "P" "0.0114473584876183" 1255_g_at "116.493632746934" "A" "0.39799368200131" 1294_at "739.927122116896" "A" "0.0668649772942343" I want to convert the row names into the first column. Currently I use something like this to make row names as the first column: d <- df names <- rownames(d) rownames(d) <- NULL data <- cbind(names,d) Is there a single

Remove index name in pandas

十年热恋 提交于 2019-11-26 09:37:02
问题 I have a dataframe like this one: In [10]: df Out[10]: Column 1 foo Apples 1 Oranges 2 Puppies 3 Ducks 4 How to remove index name foo from that dataframe? The desired output is like this: In [10]: df Out[10]: Column 1 Apples 1 Oranges 2 Puppies 3 Ducks 4 回答1: Use del df.index.name In [16]: df Out[16]: Column 1 foo Apples 1 Oranges 2 Puppies 3 Ducks 4 In [17]: del df.index.name In [18]: df Out[18]: Column 1 Apples 1 Oranges 2 Puppies 3 Ducks 4 回答2: Alternatively you can just assign None to the