Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df.eval('I = (G * H) / 10000', inplace=True)
- TypeError: unsupported operand type(s) for /: 'object' and '<class 'int'>'
- df.eval('I = G * H', inplace=True)
- my_df.eval('I = (A * B)', inplace=True)
- print(my_df.I)
- >>> 0 8
- >>> Name: I, dtype: object
- import pandas as pd
- columns = ['A', 'B', 'C']
- my_df = pd.DataFrame(columns=columns)
- my_df.loc[len(my_df)] = [2, 4, 5]
- print(my_df.dtypes)
- >>> A object
- >>> B object
- >>> C object
- >>> dtype: object
- # Convert from object to int.
- my_df[columns] = my_df[columns].astype(int)
- my_df.eval('I = (A * B) / 10000', inplace=True)
- print(my_df)
- >>> A B C I
- >>> 0 2 4 5 0.0008
Add Comment
Please, Sign In to add comment