在PySpark DataFrame中添加多个空列

时间:2018-09-14 00:13:18

标签: python pyspark

谁能建议我如何在pyspark数据框中添加多个空列。目前,我正在执行类似的操作,但无法正常工作:

         UMat(UMat&& m);
                  ^
/usr/local/include/opencv2/core/mat.hpp:2531:27: error: expected ‘,’ or ‘...’ before ‘&&’ token
     UMat& operator = (UMat&& m);
                           ^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘void cv::_InputArray::init(int, const void*, cv::Size)’:
/usr/local/include/opencv2/core/mat.inl.hpp:70:41: error: ambiguous overload for ‘operator=’ (operand types are ‘cv::Size {aka cv::Size_<int>}’ and ‘cv::Size {aka cv::Size_<int>}’)
 { flags = _flags; obj = (void*)_obj; sz = _sz; }
                                         ^
In file included from /usr/local/include/opencv2/core.hpp:58:0,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/types.hpp:1707:13: note: candidate: cv::Size_<_Tp>& cv::Size_<_Tp>::operator=(const cv::Size_<_Tp>&) [with _Tp = int]
 Size_<_Tp>& Size_<_Tp>::operator = (const Size_<_Tp>& sz)
             ^
/usr/local/include/opencv2/core/types.hpp:1714:13: note: candidate: cv::Size_<_Tp>& cv::Size_<_Tp>::operator=(cv::Size_<_Tp>) [with _Tp = int]
 Size_<_Tp>& Size_<_Tp>::operator = (Size_<_Tp>&& sz) CV_NOEXCEPT
             ^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:88:37: error: ‘array’ in namespace ‘std’ does not name a template type
 _InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
                                     ^
/usr/local/include/opencv2/core/mat.inl.hpp:88:42: error: expected ‘,’ or ‘...’ before ‘<’ token
 _InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
                                          ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputArray::_InputArray(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:89:86: error: ‘arr’ was not declared in this scope
 { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); }
                                                                                      ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:92:37: error: ‘array’ in namespace ‘std’ does not name a template type
 _InputArray::_InputArray(const std::array<Mat, _Nm>& arr)
                                     ^
/usr/local/include/opencv2/core/mat.inl.hpp:92:42: error: expected ‘,’ or ‘...’ before ‘<’ token
 _InputArray::_InputArray(const std::array<Mat, _Nm>& arr)
                                          ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputArray::_InputArray(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:93:37: error: ‘arr’ was not declared in this scope
 { init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); }
                                     ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:175:33: error: ‘cv::_OutputArray::_OutputArray’ declared as an ‘inline’ variable
 _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
                                 ^
/usr/local/include/opencv2/core/mat.inl.hpp:175:33: error: ‘int cv::_OutputArray::_OutputArray’ is not a static data member of ‘class cv::_OutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:175:33: error: template definition of non-template ‘int cv::_OutputArray::_OutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:175:28: error: ‘array’ is not a member of ‘std’
 _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
                            ^
/usr/local/include/opencv2/core/mat.inl.hpp:175:42: error: expected primary-expression before ‘,’ token
 _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
                                          ^
/usr/local/include/opencv2/core/mat.inl.hpp:175:50: error: ‘arr’ was not declared in this scope
 _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
                                                  ^
/usr/local/include/opencv2/core/mat.inl.hpp:179:33: error: ‘cv::_OutputArray::_OutputArray’ declared as an ‘inline’ variable
 _OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
                                 ^
/usr/local/include/opencv2/core/mat.inl.hpp:179:33: error: ‘int cv::_OutputArray::_OutputArray’ is not a static data member of ‘class cv::_OutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:179:33: error: template definition of non-template ‘int cv::_OutputArray::_OutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:179:28: error: ‘array’ is not a member of ‘std’
 _OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
                            ^
/usr/local/include/opencv2/core/mat.inl.hpp:179:42: error: expected primary-expression before ‘,’ token
 _OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
                                          ^
/usr/local/include/opencv2/core/mat.inl.hpp:179:50: error: ‘arr’ was not declared in this scope
 _OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
                                                  ^
/usr/local/include/opencv2/core/mat.inl.hpp:215:39: error: ‘array’ in namespace ‘std’ does not name a template type
 _OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr)
                                       ^
/usr/local/include/opencv2/core/mat.inl.hpp:215:44: error: expected ‘,’ or ‘...’ before ‘<’ token
 _OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr)
                                            ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::_OutputArray::_OutputArray(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:216:87: error: ‘arr’ was not declared in this scope
 { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
                                                                                       ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:219:39: error: ‘array’ in namespace ‘std’ does not name a template type
 _OutputArray::_OutputArray(const std::array<Mat, _Nm>& arr)
                                       ^
/usr/local/include/opencv2/core/mat.inl.hpp:219:44: error: expected ‘,’ or ‘...’ before ‘<’ token
 _OutputArray::_OutputArray(const std::array<Mat, _Nm>& arr)
                                            ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::_OutputArray::_OutputArray(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:220:51: error: ‘arr’ was not declared in this scope
 { init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
                                                   ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:290:43: error: ‘cv::_InputOutputArray::_InputOutputArray’ declared as an ‘inline’ variable
 _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
                                           ^
/usr/local/include/opencv2/core/mat.inl.hpp:290:43: error: ‘int cv::_InputOutputArray::_InputOutputArray’ is not a static data member of ‘class cv::_InputOutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:290:43: error: template definition of non-template ‘int cv::_InputOutputArray::_InputOutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:290:38: error: ‘array’ is not a member of ‘std’
 _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
                                      ^
/usr/local/include/opencv2/core/mat.inl.hpp:290:52: error: expected primary-expression before ‘,’ token
 _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
                                                    ^
/usr/local/include/opencv2/core/mat.inl.hpp:290:60: error: ‘arr’ was not declared in this scope
 _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
                                                            ^
/usr/local/include/opencv2/core/mat.inl.hpp:294:43: error: ‘cv::_InputOutputArray::_InputOutputArray’ declared as an ‘inline’ variable
 _InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
                                           ^
/usr/local/include/opencv2/core/mat.inl.hpp:294:43: error: ‘int cv::_InputOutputArray::_InputOutputArray’ is not a static data member of ‘class cv::_InputOutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:294:43: error: template definition of non-template ‘int cv::_InputOutputArray::_InputOutputArray’
/usr/local/include/opencv2/core/mat.inl.hpp:294:38: error: ‘array’ is not a member of ‘std’
 _InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
                                      ^
/usr/local/include/opencv2/core/mat.inl.hpp:294:52: error: expected primary-expression before ‘,’ token
 _InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
                                                    ^
/usr/local/include/opencv2/core/mat.inl.hpp:294:60: error: ‘arr’ was not declared in this scope
 _InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
                                                            ^
/usr/local/include/opencv2/core/mat.inl.hpp:325:49: error: ‘array’ in namespace ‘std’ does not name a template type
 _InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr)
                                                 ^
/usr/local/include/opencv2/core/mat.inl.hpp:325:54: error: expected ‘,’ or ‘...’ before ‘<’ token
 _InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr)
                                                      ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputOutputArray::_InputOutputArray(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:326:84: error: ‘arr’ was not declared in this scope
 { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); }
                                                                                    ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:329:49: error: ‘array’ in namespace ‘std’ does not name a template type
 _InputOutputArray::_InputOutputArray(const std::array<Mat, _Nm>& arr)
                                                 ^
/usr/local/include/opencv2/core/mat.inl.hpp:329:54: error: expected ‘,’ or ‘...’ before ‘<’ token
 _InputOutputArray::_InputOutputArray(const std::array<Mat, _Nm>& arr)
                                                      ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputOutputArray::_InputOutputArray(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:330:48: error: ‘arr’ was not declared in this scope
 { init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); }
                                                ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:562:21: error: ‘initializer_list’ in namespace ‘std’ does not name a template type
 Mat::Mat(const std::initializer_list<_Tp> list)
                     ^
/usr/local/include/opencv2/core/mat.inl.hpp:562:37: error: expected ‘,’ or ‘...’ before ‘<’ token
 Mat::Mat(const std::initializer_list<_Tp> list)
                                     ^
In file included from /usr/local/include/opencv2/core.hpp:54:0,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::Mat::Mat(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:565:5: error: ‘list’ was not declared in this scope
     CV_Assert(list.size() != 0);
     ^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp:566:14: error: ‘list’ was not declared in this scope
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
              ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:570:21: error: ‘initializer_list’ in namespace ‘std’ does not name a template type
 Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
                     ^
/usr/local/include/opencv2/core/mat.inl.hpp:570:37: error: expected ‘,’ or ‘...’ before ‘<’ token
 Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
                                     ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::Mat::Mat(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:574:14: error: ‘s’ does not name a type
     for(auto s : sizes)
              ^
In file included from /usr/local/include/opencv2/core.hpp:54:0,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp:576:5: error: expected ‘;’ before ‘do’
     CV_Assert(list.size() != 0);
     ^
/usr/local/include/opencv2/core/mat.inl.hpp:576:5: error: expected primary-expression before ‘do’
/usr/local/include/opencv2/core/mat.inl.hpp:576:5: error: expected ‘;’ before ‘do’
/usr/local/include/opencv2/core/mat.inl.hpp:576:5: error: expected primary-expression before ‘do’
/usr/local/include/opencv2/core/mat.inl.hpp:576:5: error: expected ‘)’ before ‘do’
/usr/local/include/opencv2/core/mat.inl.hpp:576:5: error: ‘list’ was not declared in this scope
     CV_Assert(list.size() != 0);
     ^
/usr/local/include/opencv2/core/mat.inl.hpp:577:5: error: ‘list’ was not declared in this scope
     CV_Assert(size_total == list.size());
     ^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp:578:14: error: ‘sizes’ was not declared in this scope
     Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
              ^
/usr/local/include/opencv2/core/mat.inl.hpp:578:83: error: ‘list’ was not declared in this scope
     Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
                                                                                   ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:582:21: error: ‘array’ in namespace ‘std’ does not name a template type
 Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
                     ^
/usr/local/include/opencv2/core/mat.inl.hpp:582:26: error: expected ‘,’ or ‘...’ before ‘<’ token
 Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
                          ^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::Mat::Mat(int)’:
/usr/local/include/opencv2/core/mat.inl.hpp:583:90: error: ‘arr’ was not declared in this scope
     : flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
                                                                                          ^
/usr/local/include/opencv2/core/mat.inl.hpp:588:10: error: ‘copyData’ was not declared in this scope
     if( !copyData )
          ^
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘void cv::Mat::assignTo(cv::Mat&, int) const’:
/usr/local/include/opencv2/core/mat.inl.hpp:762:11: error: ambiguous overload for ‘operator=’ (operand types are ‘cv::Mat’ and ‘const cv::Mat’)
         m = *this;
           ^
/usr/local/include/opencv2/core/mat.inl.hpp:686:6: note: candidate: cv::Mat& cv::Mat::operator=(const cv::Mat&)
 Mat& Mat::operator = (const Mat& m)
      ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.hpp:2060:10: note: candidate: cv::Mat& cv::Mat::operator=(cv::Mat)
     Mat& operator = (Mat&& m);
          ^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:1249:20: error: ‘array’ in namespace ‘std’ does not name a template type
 Mat::operator std::array<_Tp, _Nm>() const
                    ^
/usr/local/include/opencv2/core/mat.inl.hpp:1323:13: error: expected ‘,’ or ‘...’ before ‘&&’ token
 Mat::Mat(Mat&& m)
             ^
/usr/local/include/opencv2/core/mat.inl.hpp:1323:1: error: prototype for ‘cv::Mat::Mat(cv::Mat)’ does not match any in class ‘cv::Mat’
 Mat::Mat(Mat&& m)
 ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.hpp:1021:14: error: candidates are: cv::Mat::Mat(const cv::cuda::GpuMat&)
     explicit Mat(const cuda::GpuMat& m);
              ^
/usr/local/include/opencv2/core/mat.hpp:1018:37: error:                 template<class _Tp> cv::Mat::Mat(const cv::MatCommaInitializer_<_Tp>&)
     template<typename _Tp> explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:1014:37: error:                 template<class _Tp> cv::Mat::Mat(const cv::Point3_<_Tp>&, bool)
     template<typename _Tp> explicit Mat(const Point3_<_Tp>& pt, bool copyData=true);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:1010:37: error:                 template<class _Tp> cv::Mat::Mat(const cv::Point_<_Tp>&, bool)
     template<typename _Tp> explicit Mat(const Point_<_Tp>& pt, bool copyData=true);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:1006:51: error:                 template<class _Tp, int m, int n> cv::Mat::Mat(const cv::Matx<_Tp, m, n>&, bool)
     template<typename _Tp, int m, int n> explicit Mat(const Matx<_Tp, m, n>& mtx, bool copyData=true);
                                                   ^
/usr/local/include/opencv2/core/mat.hpp:1002:44: error:                 template<class _Tp, int n> cv::Mat::Mat(const cv::Vec<_Tp, m>&, bool)
     template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
                                            ^
/usr/local/include/opencv2/core/mat.hpp:997:49: error:                 template<class _Tp, long unsigned int _Nm> cv::Mat::Mat(int)
     template<typename _Tp, size_t _Nm> explicit Mat(const std::array<_Tp, _Nm>& arr, bool copyData=false);
                                                 ^
/usr/local/include/opencv2/core/mat.hpp:992:37: error:                 template<class _Tp> cv::Mat::Mat(int)
     template<typename _Tp> explicit Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:988:14: error:                 template<class _Tp, class> cv::Mat::Mat(int)
     explicit Mat(const std::initializer_list<_Tp> list);
              ^
/usr/local/include/opencv2/core/mat.hpp:983:37: error:                 template<class _Tp> cv::Mat::Mat(const std::vector<_Tp>&, bool)
     template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:965:5: error:                 cv::Mat::Mat(const cv::Mat&, const std::vector<cv::Range>&)
     Mat(const Mat& m, const std::vector<Range>& ranges);
     ^
/usr/local/include/opencv2/core/mat.hpp:955:5: error:                 cv::Mat::Mat(const cv::Mat&, const cv::Range*)
     Mat(const Mat& m, const Range* ranges);
     ^
/usr/local/include/opencv2/core/mat.hpp:945:5: error:                 cv::Mat::Mat(const cv::Mat&, const Rect&)
     Mat(const Mat& m, const Rect& roi);
     ^
/usr/local/include/opencv2/core/mat.hpp:935:5: error:                 cv::Mat::Mat(const cv::Mat&, const cv::Range&, const cv::Range&)
     Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all());
     ^
/usr/local/include/opencv2/core/mat.hpp:923:5: error:                 cv::Mat::Mat(const std::vector<int>&, int, void*, const size_t*)
     Mat(const std::vector<int>& sizes, int type, void* data, const size_t* steps=0);
     ^
/usr/local/include/opencv2/core/mat.hpp:909:5: error:                 cv::Mat::Mat(int, const int*, int, void*, const size_t*)
     Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0);
     ^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from ../src/HomeworkTwo.cpp:10:
/usr/local/include/opencv2/core/mat.inl.hpp:515:1: error:                 cv::Mat::Mat(cv::Size, int, void*, size_t)
 Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:486:1: error:                 cv::Mat::Mat(int, int, int, void*, size_t)
 Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:467:1: error:                 cv::Mat::Mat(const cv::Mat&)
 Mat::Mat(const Mat& m)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:458:1: error:                 cv::Mat::Mat(const std::vector<int>&, int, const Scalar&)
 Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:441:1: error:                 cv::Mat::Mat(int, const int*, int, const Scalar&)
 Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:450:1: error:                 cv::Mat::Mat(const std::vector<int>&, int)
 Mat::Mat(const std::vector<int>& _sz, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:433:1: error:                 cv::Mat::Mat(int, const int*, int)
 Mat::Mat(int _dims, const int* _sz, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:424:1: error:                 cv::Mat::Mat(cv::Size, int, const Scalar&)
 Mat::Mat(Size _sz, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:407:1: error:                 cv::Mat::Mat(int, int, int, const Scalar&)
 Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:416:1: error:                 cv::Mat::Mat(cv::Size, int)
 Mat::Mat(Size _sz, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:399:1: error:                 cv::Mat::Mat(int, int, int)
 Mat::Mat(int _rows, int _cols, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:393:1: error:                 cv::Mat::Mat()
 Mat::Mat()
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:1348:26: error: expected ‘,’ or ‘...’ before ‘&&’ token
 Mat& Mat::operator = (Mat&& m)
                          ^
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘cv::Mat& cv::Mat::operator=(cv::Mat)’:
/usr/local/include/opencv2/core/mat.inl.hpp:1350:18: error: ‘m’ was not declared in this scope
     if (this == &m)
                  ^
/usr/local/include/opencv2/core/mat.inl.hpp:1354:13: error: ‘m’ was not declared in this scope
     flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols; data = m.data;
             ^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:1628:22: error: ‘cv::Mat_<_Tp>::Mat_’ declared as an ‘inline’ variable
 Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
                      ^
/usr/local/include/opencv2/core/mat.inl.hpp:1628:22: error: ‘int cv::Mat_<_Tp>::Mat_’ is not a static data member of ‘class cv::Mat_<_Tp>’
/usr/local/include/opencv2/core/mat.inl.hpp:1628:22: error: template definition of non-template ‘int cv::Mat_<_Tp>::Mat_’
/usr/local/include/opencv2/core/mat.inl.hpp:1628:17: error: ‘initializer_list’ is not a member of ‘std’
 Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
                 ^
/usr/local/include/opencv2/core/mat.inl.hpp:1628:42: error: expected primary-expression before ‘>’ token
 Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
                                          ^
/usr/local/include/opencv2/core/mat.inl.hpp:1628:44: error: ‘list’ was not declared in this scope
 Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
                                            ^
/usr/local/include/opencv2/core/mat.inl.hpp:1633:28: error: ‘initializer_list’ in namespace ‘std’ does not name a template type
 Mat_<_Tp>::Mat_(const std::initializer_list<int> sizes, std::initializer_list<_Tp> list)

在应用了add_columns函数之后的输出模式中,我在0x7f41189d7e10处获得了作为生成器对象genexpr的新列:string(nullable = true)

1 个答案:

答案 0 :(得分:0)

你的代码片段对我有用,只需在里面做这个小改动:

def add_columns(dataframe, column_list):
    self = dataframe.withColumn(str(column_list[0]), f.lit(None).cast(StringType()))
    for col in column_list[1:]:
        self = self.withColumn(str(col), f.lit(None).cast(StringType()))
    return self

我返回了“self”而不是“dataframe”,以便在每次运行函数时不向数据帧添加多列。