DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DAPyScriptsDataFrame.h
1#ifndef DAPYSCRIPTSDATAFRAME_H
2#define DAPYSCRIPTSDATAFRAME_H
3#include "DAPyScriptsGlobal.h"
4#include "DAPyModule.h"
5#include <optional>
6#include <QString>
7#include <QList>
8#include "DAPyObjectWrapper.h"
9#include "numpy/DAPyDType.h"
10#include "pandas/DAPyDataFrame.h"
11
12namespace DA
13{
19class DAPYSCRIPTS_API DAPyScriptsDataFrame : public DAPyModule
20{
21public:
22 DAPyScriptsDataFrame(bool autoImport = true);
23 DAPyScriptsDataFrame(const pybind11::object& obj);
25 // 引入
26 bool import() noexcept;
27
28public:
29 // 移除dataframe的行,对应da_dataframe.da_drop_irow
30 bool drop_irow(DAPyDataFrame& df, const QList< int >& index) noexcept;
31 // 移除dataframe的列,对应da_dataframe.da_drop_icolumn
32 bool drop_icolumn(DAPyDataFrame& df, const QList< int >& index) noexcept;
33 // 插入一个空行
34 bool insert_nanrow(DAPyDataFrame& df, int r) noexcept;
35 // 插入列-全为nan
36 bool insert_column(DAPyDataFrame& df, int c, const QString& name, const QVariant& defaultvalue = QVariant()) noexcept;
37 bool insert_column(DAPyDataFrame& df, int c, const QString& name, const QVariant& start, const QVariant& stop) noexcept;
38 //
39 // 保存为txt/csv
40 bool to_csv(const DAPyDataFrame& df, const QString& path, const QString& sep) noexcept;
41 // 保存为xlsx
42 bool to_excel(const DAPyDataFrame& df, const QString& path) noexcept;
43 // 保存为pickle
44 bool to_pickle(const DAPyDataFrame& df, const QString& path) noexcept;
45 // 保存为parquet
46 bool to_parquet(const DAPyDataFrame& df, const QString& path) noexcept;
47 // 从pickle加载
48 bool from_pickle(DAPyDataFrame& df, const QString& path) noexcept;
49 // 从parquet加载
50 bool from_parquet(DAPyDataFrame& df, const QString& path) noexcept;
51 // 类型转换
52 bool astype(DAPyDataFrame& df, const QList< int >& colsIndex, const DAPyDType& dt) noexcept;
53 // 设置nan值
54 bool setnan(DAPyDataFrame& df, const QList< int >& rowsIndex, const QList< int >& colsIndex) noexcept;
55 // 转换为数值 :da_cast_to_num
56 bool cast_to_num(DAPyDataFrame& df, const QList< int >& colsIndex, pybind11::dict args) noexcept;
57 bool cast_to_datetime(DAPyDataFrame& df, const QList< int >& colsIndex, pybind11::dict args) noexcept;
58 // 设置某列为index
59 bool set_index(DAPyDataFrame& df, const QList< int >& colsIndex) noexcept;
60 // 提取一列,此函数如果失败返回一个none
61 DAPySeries itake_column(DAPyDataFrame& df, int col) noexcept;
62 // 在col位置插入series
63 bool insert_at(DAPyDataFrame& df, int col, const DAPySeries& series) noexcept;
64 // dropna(axis=0,how="any")
65 bool dropna(DAPyDataFrame& df,
66 int axis = 0,
67 const QString& how = QStringLiteral("any"),
68 const QList< int >& indexs = QList< int >(),
69 std::optional< int > thresh = std::nullopt) noexcept;
70 // fillna()
71 bool fillna(DAPyDataFrame& df, double value, int limit) noexcept;
72 // interpolate()
73 bool interpolate(DAPyDataFrame& df, const QString& method, int order, int limit) noexcept;
74 // ffillna()
75 bool ffillna(DAPyDataFrame& df, int axis, int limit) noexcept;
76 // bfillna()
77 bool bfillna(DAPyDataFrame& df, int axis, int limit) noexcept;
78 // dropduplicates(keep = "first","last")
79 bool dropduplicates(DAPyDataFrame& df, const QString& keep, const QList< int >& indexs) noexcept;
80 // nstdfilteroutlier()
81 bool nstdfilteroutlier(DAPyDataFrame& df, double n, int axis, const QList< int >& indexs) noexcept;
82 // clipoutlier()
83 bool clipoutlier(DAPyDataFrame& df, double lowervalue, double uppervalue, int axis) noexcept;
84 // querydatas()
85 bool queryDatas(DAPyDataFrame& df, const QString& expr) noexcept;
86 // searchdata()
87 QList< QPair< int, int > > searchData(const DAPyDataFrame& df, const QString& expr) noexcept;
88 // eval
89 bool evalDatas(DAPyDataFrame& df, const QString& expr) noexcept;
90 // 排序sort()
91 bool sort(DAPyDataFrame& df, const QString& by, bool ascending) noexcept;
92 // dataselect()
93 bool dataselect(DAPyDataFrame& df, double lowervalue, double uppervalue, const QString& index) noexcept;
94
95 // 创建数据透视表
96 DAPyDataFrame pivotTable(const DAPyDataFrame& df,
97 const QStringList& value,
98 const QStringList& index,
99 const QStringList& columns,
100 const QString& aggfunc,
101 bool margins,
102 const QString& marginsName,
103 bool sort) noexcept;
104};
105} // namespace DA
106#endif // DAPYSCRIPTSDATAFRAME_H
对numpy.dtype的封装
Definition DAPyDType.h:37
非模板类的DataFrame
Definition DAPyDataFrame.h:19
模块的基类
Definition DAPyModule.h:13
对da_dataframe.py的封装,集成了dataframe的操作
Definition DAPyScriptsDataFrame.h:20
对Pandas.Series的Qt封装
Definition DAPySeries.h:22
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44