68
68
quot (x) = Expr (:quote , x)
69
69
70
70
function Base. Array (x:: PandasWrapped )
71
- c = np[ : asarray] (x. pyo)
71
+ c = np. asarray (x. pyo)
72
72
if typeof (c). parameters[1 ] == PyObject
73
73
out = Array {Any} (undef, size (x))
74
74
for idx in eachindex (out)
83
83
84
84
function Base. values (x:: PandasWrapped )
85
85
# Zero-copy conversion to a Julia native type is possible
86
- x_kind = x. pyo[ : dtype][ : kind]
86
+ x_kind = x. pyo. dtype. kind
87
87
if x_kind in [" i" , " u" , " f" , " b" ]
88
- pyarray = convert (PyArray, x. pyo[ " values" ] )
88
+ pyarray = convert (PyArray, x. pyo. " values" )
89
89
unsafe_wrap (Array, pyarray. data, size (pyarray))
90
90
else # Convert element by element otherwise
91
91
collect (x)
@@ -132,7 +132,7 @@ function pyattr(class, jl_method, py_method)
132
132
quote
133
133
function $ (esc (jl_method))(pyt:: $class , args... ; kwargs... )
134
134
new_args = fix_arg .(args)
135
- method = pyt. pyo[ $ (string (py_method))]
135
+ method = pyt. pyo. $ (string (py_method))
136
136
pyo = pycall (method, PyObject, new_args... ; kwargs... )
137
137
wrapped = pandas_wrap (pyo)
138
138
end
@@ -169,31 +169,31 @@ macro pyasvec(class)
169
169
offset = should_offset (pyt, args... )
170
170
new_args = tuple ([fix_arg (arg, offset) for arg in args]. .. )
171
171
new_args = (length (new_args)== 1 ? new_args[1 ] : new_args)
172
- pyo = pycall (pyt. pyo[ : __getitem__] , PyObject, new_args)
172
+ pyo = pycall (pyt. pyo. __getitem__, PyObject, new_args)
173
173
pandas_wrap (pyo)
174
174
end
175
175
176
176
function $ (esc (:setindex! ))(pyt:: $class , value, idxs... )
177
177
offset = should_offset (pyt, idxs... )
178
178
new_idx = [fix_arg (idx, offset) for idx in idxs]
179
179
if length (new_idx) > 1
180
- pandas_wrap (pycall (pyt. pyo[ : __setitem__] , PyObject, tuple (new_idx... ), value))
180
+ pandas_wrap (pycall (pyt. pyo. __setitem__, PyObject, tuple (new_idx... ), value))
181
181
else
182
- pandas_wrap (pycall (pyt. pyo[ : __setitem__] , PyObject, new_idx[1 ], value))
182
+ pandas_wrap (pycall (pyt. pyo. __setitem__, PyObject, new_idx[1 ], value))
183
183
end
184
184
end
185
185
end
186
186
187
187
if class in [:Iloc , :Loc , :Ix ]
188
188
length_expr = quote
189
189
function $ (esc (:length ))(x:: $class )
190
- x. pyo[ : obj][ : __len__] ()
190
+ x. pyo. obj. __len__ ()
191
191
end
192
192
end
193
193
else
194
194
length_expr = quote
195
195
function $ (esc (:length ))(x:: $class )
196
- x. pyo[ : __len__] ()
196
+ x. pyo. __len__ ()
197
197
end
198
198
end
199
199
end
@@ -209,16 +209,16 @@ macro pyasvec(class)
209
209
end
210
210
211
211
212
- @pytype DataFrame ()-> pandas_raw[ : core][ : frame][ " DataFrame" ]
213
- @pytype Iloc ()-> pandas_raw[ : core][ : indexing][ " _iLocIndexer" ]
214
- @pytype Loc ()-> pandas_raw[ : core][ : indexing][ " _LocIndexer" ]
215
- @pytype Ix ()-> pandas_raw[ : core][ : indexing][ " _IXIndexer" ]
216
- @pytype Series ()-> pandas_raw[ : core][ : series][ " Series" ]
217
- @pytype MultiIndex ()-> pandas_raw[ : core][ : index][ " MultiIndex" ]
218
- @pytype Index ()-> pandas_raw[ : core][ : index][ " Index" ]
219
- @pytype GroupBy ()-> pandas_raw[ : core][ : groupby][ " DataFrameGroupBy" ]
220
- @pytype SeriesGroupBy ()-> pandas_raw[ : core][ : groupby][ " SeriesGroupBy" ]
221
- @pytype Rolling () -> pandas_raw[ : core][ : window][ " Rolling" ]
212
+ @pytype DataFrame ()-> pandas_raw. core. frame. " DataFrame"
213
+ @pytype Iloc ()-> pandas_raw. core. indexing. " _iLocIndexer"
214
+ @pytype Loc ()-> pandas_raw. core. indexing. " _LocIndexer"
215
+ @pytype Ix ()-> pandas_raw. core. indexing. " _IXIndexer"
216
+ @pytype Series ()-> pandas_raw. core. series. " Series"
217
+ @pytype MultiIndex ()-> pandas_raw. core. index. " MultiIndex"
218
+ @pytype Index ()-> pandas_raw. core. index. " Index"
219
+ @pytype GroupBy ()-> pandas_raw. core. groupby. " DataFrameGroupBy"
220
+ @pytype SeriesGroupBy ()-> pandas_raw. core. groupby. " SeriesGroupBy"
221
+ @pytype Rolling () -> pandas_raw. core. window. " Rolling"
222
222
223
223
@pyattr GroupBy app apply
224
224
@pyattr Rolling app apply
@@ -246,12 +246,12 @@ pyattr_set([DataFrame, Series], :T, :abs, :align, :any, :argsort, :asfreq, :asof
246
246
pyattr_set ([DataFrame], :groupby )
247
247
pyattr_set ([Series, DataFrame], :rolling )
248
248
249
- Base. size (x:: Union{Loc, Iloc, Ix} ) = x. pyo[ : obj][ : shape]
249
+ Base. size (x:: Union{Loc, Iloc, Ix} ) = x. pyo. obj. shape
250
250
Base. size (df:: PandasWrapped , i:: Integer ) = size (df)[i]
251
- Base. size (df:: PandasWrapped ) = df. pyo[ : shape]
251
+ Base. size (df:: PandasWrapped ) = df. pyo. shape
252
252
253
- Base. isempty (df:: PandasWrapped ) = df. pyo[ : empty]
254
- Base. empty! (df:: PandasWrapped ) = df. pyo[ : drop] (df. pyo[ : index] , inplace= true )
253
+ Base. isempty (df:: PandasWrapped ) = df. pyo. empty
254
+ Base. empty! (df:: PandasWrapped ) = df. pyo. drop (df. pyo. index, inplace= true )
255
255
256
256
should_offset (:: Any , args... ) = false
257
257
should_offset (:: Union{Iloc, Index} , args... ) = true
267
267
268
268
for attr in [:index , :columns ]
269
269
@eval function $attr (x:: PandasWrapped )
270
- pandas_wrap (x. pyo[ $ (string (attr))] )
270
+ pandas_wrap (x. pyo. $ (string (attr)))
271
271
end
272
272
end
273
273
@@ -304,7 +304,7 @@ for m in [:read_pickle, :read_csv, :read_html, :read_json, :read_excel, :read_ta
304
304
end
305
305
306
306
function show (io:: IO , df:: PandasWrapped )
307
- s = df. pyo[ : __str__] ()
307
+ s = df. pyo. __str__ ()
308
308
println (io, s)
309
309
end
310
310
328
328
329
329
for m in [:from_arrays , :from_tuples ]
330
330
@eval function $m (args... ; kwargs... )
331
- f = pandas_raw[ " MultiIndex" ] [string ($ (quot (m)))]
331
+ f = pandas_raw. " MultiIndex" [string ($ (quot (m)))]
332
332
res = pycall (f, PyObject, args... ; kwargs... )
333
333
pandas_wrap (res)
334
334
end
@@ -342,7 +342,7 @@ for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul
342
342
(:& , :__and__ , :__and__ ), (:| , :__or__ , :__or__ )]
343
343
@eval begin
344
344
function $ (jl_op)(x:: PandasWrapped , y)
345
- res = x. pyo[ $ (string (py_op))] (y)
345
+ res = x. pyo. $ (string (py_op))(y)
346
346
pandas_wrap (res)
347
347
end
348
348
@@ -351,28 +351,28 @@ for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul
351
351
end
352
352
353
353
function $ (jl_op)(y, x:: PandasWrapped )
354
- res = x. pyo[ $ (string (py_opᵒ))] (y)
354
+ res = x. pyo. $ (string (py_opᵒ))(y)
355
355
pandas_wrap (res)
356
356
end
357
357
end
358
358
end
359
359
360
360
for op in [(:- , :__neg__ )]
361
361
@eval begin
362
- $ (op[1 ])(x:: PandasWrapped ) = pandas_wrap (x. pyo[ $ (quot (op[2 ]))] ())
362
+ $ (op[1 ])(x:: PandasWrapped ) = pandas_wrap (x. pyo. $ (quot (op[2 ]))())
363
363
end
364
364
end
365
365
366
366
function setcolumns! (df:: PandasWrapped , new_columns)
367
- df. pyo[ : __setattr__] (" columns" , new_columns)
367
+ df. pyo. __setattr__ (" columns" , new_columns)
368
368
end
369
369
370
370
function deletecolumn! (df:: DataFrame , column)
371
- df. pyo[ : __delitem__] (column)
371
+ df. pyo. __delitem__ (column)
372
372
end
373
373
374
- name (s:: Series ) = s. pyo[ : name]
375
- name! (s:: Series , name) = s. pyo[ : name] = name
374
+ name (s:: Series ) = s. pyo. name
375
+ name! (s:: Series , name) = s. pyo. name = name
376
376
377
377
include (" operators_v6.jl" )
378
378
@@ -381,17 +381,17 @@ function DataFrame(pairs::Pair...)
381
381
end
382
382
383
383
function index! (df:: PandasWrapped , new_index)
384
- df. pyo[ : index] = new_index
384
+ df. pyo. index = new_index
385
385
df
386
386
end
387
387
388
388
function Base. eltype (s:: Series )
389
389
dtype_map = Dict (
390
- np[ : dtype] (" int64" ) => Int64,
391
- np[ : dtype] (" float64" ) => Float64,
392
- np[ : dtype] (" object" ) => String,
390
+ np. dtype (" int64" ) => Int64,
391
+ np. dtype (" float64" ) => Float64,
392
+ np. dtype (" object" ) => String,
393
393
)
394
- get (dtype_map, s. pyo[ : dtype] , Any)
394
+ get (dtype_map, s. pyo. dtype, Any)
395
395
end
396
396
397
397
function Base. eltype (df:: DataFrame )
@@ -411,23 +411,23 @@ function Base.map(f::Function, s::Series)
411
411
end
412
412
413
413
function Base. map (x, s:: Series ; na_action= nothing )
414
- pandas_wrap (s. pyo[ : map] (x, na_action))
414
+ pandas_wrap (s. pyo. map (x, na_action))
415
415
end
416
416
417
417
function Base. get (df:: PandasWrapped , key, default)
418
- pandas_wrap (df. pyo[ : get] (key, default= default))
418
+ pandas_wrap (df. pyo. get (key, default= default))
419
419
end
420
420
421
421
function Base. getindex (s:: Series , c:: CartesianIndex{1} )
422
422
s[c[1 ]]
423
423
end
424
424
425
425
function Base. copy (df:: PandasWrapped )
426
- pandas_wrap (df. pyo[ : copy] ())
426
+ pandas_wrap (df. pyo. copy ())
427
427
end
428
428
429
429
function ! (df:: PandasWrapped )
430
- pandas_wrap (df. pyo[ : __neg__] ())
430
+ pandas_wrap (df. pyo. __neg__ ())
431
431
end
432
432
433
433
include (" tabletraits.jl" )
@@ -442,7 +442,7 @@ function DataFrame(obj)
442
442
end
443
443
444
444
function has_named_attr (x:: Index , s)
445
- return x. pyo[ : __contains__] (Symbol (s))
445
+ return x. pyo. __contains__ (Symbol (s))
446
446
end
447
447
448
448
named_index (x:: DataFrame ) = columns (x)
0 commit comments