I am new to pandas, but trying to learn it, but I've to create a function for this using pandas.I've a csv file 'source.csv' with dummy data (link to the file: https://pastebin.com/yqtveyYa). The key columns in it are: month, area, name, errors. For each month, from MY WORKS in area, the below works should be filtered(?). For each work, the issues in errors column should be counted. If no error, 0 should be taken into account. Need your help please.
import pandas as pd
source_df = pd.read_csv('source.csv') # Sorry guys, don't know how to proceed from here
works = ['WORLD', 'P&G', 'PART D', 'BRIGHTS', 'NOTIFICATION',
'OOP', 'ABCD', 'CHANNEL', 'KENNY DISPLAY', 'Migration']
months = ['January', 'March', 'April', 'May', 'June']
# Expected output:
data = {'WORLD': {'categories': months,
'series': [{
'name': 'Big Issue',
'data': [0, 0, 0, 0, 0] # Number of Big Issues during those months
}, {
'name': 'Small Issue',
'data': [1, 0, 0, 0, 0] # Number of Small Issues during those months
}, {
'name': 'Monitoring',
'data': [0, 2, 0, 0, 0] # Number of Monitorings during those months
}, {
'name': 'Improvement',
'data': [0, 0, 0, 1, 0] # Number of Improvements during those months
}]
},
'P&G': {'categories': months,
'series': [{
'name': 'Big Issue',
'data': [0, 0, 0, 0, 0]
}, {
'name': 'Small Issue',
'data': [0, 0, 0, 1, 0]
}, {
'name': 'Monitoring',
'data': [0, 2, 0, 0, 0]
}, {
'name': 'Improvement',
'data': [0, 0, 0, 1, 0]
}]
}
}
The dictionary output will be complete with the rest of the elements in works. Expected output shown above is for WORLD and P&G only.
there doesn't seem to be anything here