excel表中的数据存储如下:
Area | Product1 | Product2 | Product3
| sales|sales.Value| sales |sales.Value | sales |sales.Value
Location1 | 20 | 20000 | 25 | 10000 | 200 | 100
Location2 | 30 | 30000 | 3 | 12300 | 213 | 10
Run Code Online (Sandbox Code Playgroud)
产品名称是给定月份的1000个左右区域中的每一个的两行"销售额"和"销售价值"的2个单元的合并.同样,过去5年每个月都有单独的文件.此外,新产品已在不同月份添加和删除.所以不同的月份文件可能如下所示:
Area | Product1 | Product4 | Product3
Run Code Online (Sandbox Code Playgroud)
论坛能否建议使用熊猫阅读此数据的最佳方式?我不能使用索引,因为每个月的产品列都不同
理想情况下,我想将上面的初始格式转换为:
Area | Product1.sales|Product1.sales.Value| Product2.sales |Product2.sales.Value |
Location1 | 20 | 20000 | 25 | 10000 |
Location2 | 30 | 30000 | 3 | 12300 |
Run Code Online (Sandbox Code Playgroud)
import pandas as …Run Code Online (Sandbox Code Playgroud) 嗯,我正在开发一个可以改善公司工作的应用程序。为此,我需要在没有对话框的情况下创建、保存和读取文件。
我在文档和互联网的帮助下创建了这段代码:
const electron = require('electron');
let fs = require('fs'), app = electron.remote;
let localData, fileName = "appdata.json";
function loadAppData() {
fs.readFile(fileName, (err, data) => {
if (err) {
console.log("There was a problem reading the data!");
// console.log(err);
} else {
console.log("Data loaded!");
localData = JSON.parse(data);
console.log(localData);
}
});
}
function saveAppData(content) {
content = JSON.stringify(content);
fs.writeFile(fileName, content, (err) => {
if (err) {
console.log("There was a problem saving data!");
// console.log(err);
} else {
console.log("Data saved correctly!");
loadAppData();
} …Run Code Online (Sandbox Code Playgroud) read-data ×2
electron ×1
excel ×1
filesystems ×1
javascript ×1
pandas ×1
python ×1
saving-data ×1