1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//! Type conversion utilities between PandRS and SciRS2/ndarray types.
//!
//! All functions in this module are gated behind the `scirs2` feature flag.
use CoreError;
use ;
use crate;
use crateDataFrame;
use crateSeries;
/// Convert a numeric PandRS `Series<f64>` to an ndarray `Array1<f64>`.
///
/// # Errors
///
/// Returns an error if the Series is empty.
///
/// # Examples
///
/// ```rust
/// # #[cfg(feature = "scirs2")]
/// # {
/// use pandrs::Series;
/// use pandrs::scirs2_integration::conversion::series_to_array1;
///
/// let series = Series::new(vec![1.0f64, 2.0, 3.0], Some("values".to_string())).expect("ok");
/// let arr = series_to_array1(&series).expect("conversion ok");
/// assert_eq!(arr.len(), 3);
/// # }
/// ```
/// Convert an ndarray `Array1<f64>` to a PandRS `Series<f64>`.
///
/// # Arguments
///
/// * `arr` - The ndarray Array1 to convert
/// * `name` - Optional name for the resulting Series
///
/// # Errors
///
/// Returns an error if the array is empty.
/// Convert selected numeric columns of a DataFrame to an ndarray `Array2<f64>`.
///
/// The resulting array has shape `(n_rows, n_cols)` where columns are in the
/// same order as provided in the `columns` argument.
///
/// # Arguments
///
/// * `df` - The source DataFrame
/// * `columns` - Slice of column names to include (must be numeric columns)
///
/// # Errors
///
/// Returns an error if:
/// - Any requested column does not exist
/// - Any column cannot be converted to f64
/// - The DataFrame is empty
/// Convert an ndarray `Array2<f64>` to a DataFrame with the specified column names.
///
/// # Arguments
///
/// * `arr` - The ndarray Array2 with shape `(n_rows, n_cols)`
/// * `columns` - Column names (must have the same length as `arr.ncols()`)
///
/// # Errors
///
/// Returns an error if the number of column names does not match the array's
/// column count, or if column names are duplicate.