Appearance
Get first row value of a given column โ
Here's an example of how you can get the first row value of a given column in a Pandas DataFrame in Python:
Get the first row value of a given column in a Pandas DataFrame in Python
python
import pandas as pd
# Create a sample dataframe
df = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6], 'C':[7,8,9]})
# Get the first row value of column 'B'
first_row_value = df.at[0, 'B']
print(first_row_value)
# Output: 4
<div class="alert alert-info flex not-prose">Watch a video course Python - The Practical Guide
</div>
You can also use df.loc[0,'B'] or df['B'][0] instead of df.at[0, 'B'] to get first row value of column 'B'.