Colleagues, please tell me: 1. I read .csv (semicolon separator). We have to play with the encoding, as there is a Russian text 2. Grouped and summed 3. Instead of the sum, I get concatenation
Question: instead of concatenation, you need a normal amount (.csv = https://transfiles.ru/kq9g5 ), (.xlsx = https://transfiles.ru/5t38n )
Listing:
import xlwt import xlrd import csv import codecs import openpyxl from openpyxl import Workbook from openpyxl.utils.dataframe import dataframe_to_rows import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.read_csv('C:\py3\Test1\Test2.csv', sep=';', encoding = "866") df.head(10) #Создаём файл Pivot.xlsx df1 = df.groupby('Global Dimension 2 Code')['Amount'].sum() df1.to_csv('C:\py3\Test1\Pivot.csv') df11 = pd.read_csv('C:\py3\Test1\Pivot.csv') w11 = pd.ExcelWriter('C:\py3\Test1\Pivot.xlsx') df11.to_excel(w11, sheet_name='Pivot', index=False, engine='xlsxwriter') w11.save()