Delete a column for a table numpy
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.
Delete a column for a table numpy
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
SQL Server DDL script to add (or delete) the same set of columns for each table in a database?
How to delete a column from a table and move the rest to the left without affecting the previous tables in excel vba
Inserting rows and columns into a table numpy
Delete the column for the particular value
Can not delete a column containing multiple tables
How to add a column to a table numpy
How to delete an object from a table numpy without knowing the index
The combination of & ldquo; by & rdquo; and & ldquo; on & rdquo; join and create a summary column for data.table
How to get the last column of the table NumPy 2D ignorant nan in Python?
Delete all columns in a table if their names follow a specific pattern in SQL Server
Updated just from an existing date and time column for all tables
Name the columns for data.table in R
In a One to One relationship, do I delete a column from the table ID?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK