#df
index a b c
1 2 3 4
2 3 4 5
df[["a","c"]] # But index no. is also coming, so how to remove the index no.?
You can use DataFrame. to_string(index=False) on the DataFrame object to print. To result DataFrame. to_string() function is a string of the DataFrame without indices.
To select a single column, use square brackets [] with the column name of the column of interest.
To select all columns except one column in Pandas DataFrame, we can use df. loc[:, df. columns != <column name>].
DataFrames and Series will always have an index, you can use:
df[["a","c"]].values
output:
array([[2, 4],
[3, 5]], dtype=int64)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With