Answers for "drop date column pandas"

3

drop a column from dataframe

df = df.drop('column_name', 1)
Posted by: Guest on August-25-2020
1

delete columns pandas

df = df.drop(df.columns[[0, 1, 3]], axis=1)
Posted by: Guest on August-22-2020
1

pandas remove time from date

# If opening_date is currently a timestamp: 2021-01-09 00:00:00
opening_date = pd.to_datetime(opening_date).date()
print(opening_date) 

# Result: 2021-01-09
Posted by: Guest on April-09-2021
0

pandas drop 1970

new_df = df[(df['Delivery Date'].dt.year != 1970)]
Posted by: Guest on October-13-2021
-2

drop a column from dataframe

#to drop by column number instead of by column label, try this to delete, e.g. the 1st, 2nd and 4th columns
df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index
Posted by: Guest on August-25-2020

Python Answers by Framework

Browse Popular Code Answers by Language