gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
what is the code in pandas to add column in table
- User
what is the code in pandas to add column in table
- Assistant
To add a column in a Pandas DataFrame, you can use the following code:
import pandas as pd # Create or load a DataFrame df = pd.DataFrame({'Name': ['John', 'Alice', 'Bob'], 'Age': [25, 30, 35]}) # Add a new column df['Height'] = [175, 165, 180] # Print the updated DataFrame print(df)This code adds a new column called "Height" to the existing DataFrame "df" and assigns the specified values to it. The resulting DataFrame will have the new column included.