3

Delete a column for a table numpy

 2 years ago
source link: https://www.codesd.com/item/delete-a-column-for-a-table-numpy.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Delete a column for a table numpy

advertisements

I have a numpy array of dimension (48, 366, 3) and I want to remove the last column from the array to make it (48, 365, 3). What is the best way to do that? (All the entries are integers. I'm using Python v2.6)


You could try numpy.delete:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.delete.html

or just get the slice of the array you want and write it to a new array.

For example:

a = np.random.randint(0,2, size=(48,366,3))
b = np.delete(a, np.s_[-1:], axis=1)
print b.shape # <--- (48,365,3)

or equivalently:

b = np.delete(a, -1, axis=1)

b = a[:,:-1,:]

Related Articles

Delete a column from a table without changing the environment

I'm working on Oracle SQL database, quite big database. One of (among 150 tables) this table has to be changed because it's redundant (it can be generated through a join). I have been asked to delete a column from this table, to get rid of the redund

SQL Server DDL script to add (or delete) the same set of columns for each table in a database?

How would one write a sql server DDL script that can: For each table in database: add column CreatedBy add column CreateDate add column UpdatedBy add column UpdatedDate Also, if the particular column already exists on the table, just skip that column

How to delete a column from a table and move the rest to the left without affecting the previous tables in excel vba

I have a workbook that contains table of data with fixed column E to S and unfixed rows. Every week i copy this table into another workbook called 'Summary'. I need to do some calculation for the table but first i need to delete data on column P and

Inserting rows and columns into a table numpy

I would like to insert multiple rows and columns into a numpy array. If I have a square array of length n_a, e.g.: n_a = 3 a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) and I would like to get a new array with size n_b, which contains array a and z

Delete the column for the particular value

Using Sql Server 2005 Table1 ID Name Value 001 Rajesh 90 002 Suresh 100 003 Mahesh 200 004 Virat 400 ... I want to delete the value from the table1 for the particular id Tried Query Delete value from table1 where id = '001' The above query is not wor

Can not delete a column containing multiple tables

Whenever I have two tables in the same column, I get this error. Create a table in columns (ie B1:C3) Create another table below that table (ie B5:C7) Right-click on column B Is the "Delete" option grayed out (unavailable)? Convert the second ta

How to add a column to a table numpy

I am trying to add one column to the array created from recfromcsv. In this case it's an array: [210,8] (rows, cols). I want to add a ninth column. Empty or with zeroes doesn't matter. from numpy import genfromtxt from numpy import recfromcsv import

How to delete an object from a table numpy without knowing the index

is it possible to delete an object from a numpy array without knowing the index of the object but instead knowing the object itself? i have seen that it is possible using the index of the object using the np.delete function, but i'm looking for a way

The combination of & ldquo; by & rdquo; and & ldquo; on & rdquo; join and create a summary column for data.table

I have two datasets, one a detailed dataset of weight's and another that's supposed to be a summary dataset. I am trying to create the summary dataset by joining the detail dataset and aggregating, but it isn't working as expected. Here's a sample co

How to get the last column of the table NumPy 2D ignorant nan in Python?

I have a NumPy 2D array as shown below: data.dat X1 X2 X3 X4 1 1 1 1 2 2 4 2 3 3 9 3 4 4 16 4 5 5 25 5 6 6 36 6 7 nan 49 7 8 nan 64 8 9 nan 81 nan 10 nan nan nan Now how do I output the last element of each column ignoring nan in the array. I tried w

Delete all columns in a table if their names follow a specific pattern in SQL Server

I have a table from which I need to drop multiple columns that follow a pattern. Say columns names in my table are (A1, A2, A3, B1, B2, B3) and I need to drop all columns that starts with a B (B1, B2, B3). I was able to pull those in a separate query

Updated just from an existing date and time column for all tables

I'm trying to create a query that updates the timestamp of all existent rows of a specific table. Below is an example table to exemplify: "DateAndTime"; ID; value "2014-04-01 00:00:03"; 44; 10 "2014-04-01 00:00:03"; 45 ; 120

Name the columns for data.table in R

I have a data.table of the form nrow V1 V2 V3 V4 V5 V6 V7 V8 1: 1 chr20 C4b 6382078 C4b 6381944 reg - Thymus_M_GSM1328751 2: 2 chr8 Rpl4 68832532 Rpl4 68832743 reg + Thymus_M_GSM1328751 I want to name the columns as ("Chromosome", "Start_Ge

In a One to One relationship, do I delete a column from the table ID?

I have the following 2 tables in MySQL: Customer(Id, Firstname, Lastname...) Bonus(Id, CustomerId, Value, ...) The relation is One-To-One, every customer has only one bonus.(the CustomerId is unique in the Bonus Table) Q: Should I drop the Id column

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK