I like VScode
In VScode
Move the mouse cursor to the left of the line number and click to add a red circle
Go to the debug console screen, enter the variable name and press the enter key to check various things I'm having trouble displaying the data frame properly </ font>
Press cmd + shift + P to open the command palette Type "launch" and Click Open launch.json
Add "" redirectOutput ": true" and save by overwriting (don't forget "," at the end of the previous line)
Finish debugging once and start debugging again. Try print (df) on the debug console Data frames are arranged and arranged for easy viewing </ font>
You can also write multi-line processing with sht + Enter
↓ Execution result
Operating environment: Mac, Python3.7
Sample code to be debugged:
# create test data
a = 15
import pandas as pd
df = pd.DataFrame(
columns = ['name', 'gender', 'age'],
data = [
['john', 'man', 25],
['yoko', 'woman', 28],
['kevin', 'man', 45]
]
)
# processing
a = a - 1
df['age'] = df['age'] - 10
Code used in the extra debug console:
for age_hosei in [10, -10]:
print('--------------------------')
print('age_hosei', age_hosei)
tmp = df.copy()
print('tmp:\n', tmp)
tmp['age'] = tmp['age'] + age_hosei
result = tmp.groupby('gender')['age'].sum()
print('result:\n', result)
Recommended Posts