select 2 cols from dataframe python pandas
# Convert the dictionary into DataFrame
df = pd.DataFrame(data)
# select two columns
df[['Name', 'Qualification']]
select 2 cols from dataframe python pandas
# Convert the dictionary into DataFrame
df = pd.DataFrame(data)
# select two columns
df[['Name', 'Qualification']]
filter dataframe by two columns
#tl;dr use the '&' opperator and not the word 'and'
print(df)
OUTPUT
Name Age
0 Joe 23
1 Tom 54
2 Joe 34
3 Tom 42
4 Joe 23
5 Tom 54
6 Joe 34
7 Tom 42
tom_and_42 = df[(df["Name"]=="Tom") & (df["Age"]==42)]
print(tom_and_42)
OUTPUT
Name Age
3 Tom 42
7 Tom 42
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us