How do you create a DataFrame with a column named 'current_amount'?
1
Times asked
Mar 2026
Last seen
Mar 2026
First seen
💡 Model Answer
You can create a pandas DataFrame and add a column named 'current_amount' in several ways:
- During construction:
import pandas as pd
df = pd.DataFrame({'current_amount': [100, 200, 300]})
- After construction by assignment:
df = pd.DataFrame()
df['current_amount'] = [100, 200, 300]
- Using a list of dictionaries:
data = [{'current_amount': 100}, {'current_amount': 200}]
df = pd.DataFrame(data)
All three approaches result in a DataFrame with a single column named 'current_amount'. The choice depends on whether you already have other columns or data structures to merge.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500