Answers for "function return two dataframe python"

2

select 2 cols from dataframe python pandas

# Convert the dictionary into DataFrame 
df = pd.DataFrame(data)
  
# select two columns
df[['Name', 'Qualification']]
Posted by: Guest on May-10-2021
1

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
Posted by: Guest on July-21-2021

Code answers related to "function return two dataframe python"

Python Answers by Framework

Browse Popular Code Answers by Language