Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- path1 = r'path to the csv table'
- path2 = r'path to the csv table'
- #1
- ins_left = pd.read_csv(path1)
- ins_right = pd.read_csv(path2)
- print(ins_left.head())
- #2
- print(ins_left.info(), ins_right.info(), sep='\n')
- print(ins_right.isnull.any(), ins_left.isnull.any(), sep='\n')
- #3
- ins_right = ins_right.dropna()
- ins_left = ins_left.dropna()
- #4
- ins_left = ins_left.drop_duplicates()
- ins_right = ins_right.drop_duplicates()
- df = pd.merge('column name from the first table', 'column name from the second table')
- print(df.info())
- #5
- female = pd.DataFrame(ins_left[(15 <= ins_left.age) & (ins_left.age <= 75)])
- print(female.head(20))
- #6
- df['cigs2'] = df['cigs2'].mask(df['cigs'] < 10, 1)
- df['cigs2'] = df['cigs2'].mask((df['cigs'] >= 10) & (df['cigs'] < 20), 2)
- df['cigs2'] = df['cigs2'].mask(df['cigs'] > 20, 3)
- print(df.loc[df['cigs2'] == 1, df['age'].mean()])
- print(df.loc[df['cigs2'] == 2, df['age'].mean()])
- print(df.loc[df['cigs2'] == 3, df['age'].mean()])
- #8
- df1 = df[]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement