pandas 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01ae8d45320fa67aa7d7ae6b131c777ec2cd88fb
4
- data.tar.gz: 1cc5bffdfe6f376cc2bbd19c67354c70bec0dd8d
3
+ metadata.gz: eca4c00765b7d95dbfc98d051507dfb3d65e459d
4
+ data.tar.gz: e8dd5363b7a711aa3284120834cec25ecf04ff17
5
5
  SHA512:
6
- metadata.gz: 9b2457bd1efb1b291ff11570dd69f3ee9b95b52e4a631993833c962fd83a216e9b08afd52a2a1a41028c541a895ae3678296cd60244d263d91d601a0a8b0966a
7
- data.tar.gz: 403ec721bc39c1245b1c82f1255dad2ad8462218b4d48fe30a94fbdba838bff17b124b5e731037c438fdcbdd5806878a166a9cc3dc94c28e4fe4351c5f80ae22
6
+ metadata.gz: c7be111f377beb778b0a6ca2ef4418f2b91a116cfd19e598d8d54c889aa6561fdbc296086f9fa0836bdc3177db615b919ecfb2c95edbfdb838c671d0b31e693d
7
+ data.tar.gz: e381e982b8e8ff1c490809fea1d6fc97cd67a92186f3e1966b3784e8c43795dff735f9225593389e136c473ee0c357ac0ea54368aa6912dda9a82a84724347a7
data/CHANGES.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # The chenge history of Pandas wrapper for Ruby
2
2
 
3
+ ## 0.3.0
4
+
5
+ * Fix the module path of `DatetimeIndex` to support pandas < 0.20
6
+
7
+ Fixes #5
8
+
9
+ *Daniel Baark*
10
+
11
+ * Support to pass an AR model class to `read_sql_table` instead of both `table_name` and `conn`
12
+
3
13
  ## 0.2.0
4
14
 
5
15
  * Support a connection of ActiveRecord in `read_sql_table` and `read_sql_query`
@@ -24,7 +24,11 @@ module Pandas
24
24
  MultiIndex = self.core.indexing.MultiIndex
25
25
  MultiIndex.__send__ :register_python_type_mapping
26
26
 
27
- DatetimeIndex = self.core.indexes.datetimes.DatetimeIndex
27
+ DatetimeIndex = if self.__version__ >= '0.20'
28
+ self.core.indexes.datetimes.DatetimeIndex
29
+ else
30
+ self.tseries.index.DatetimeIndex
31
+ end
28
32
  DatetimeIndex.__send__ :register_python_type_mapping
29
33
 
30
34
  Index = self.core.index.Index
@@ -38,7 +42,18 @@ module Pandas
38
42
 
39
43
  IO = self.io
40
44
 
41
- def self.read_sql_table(table_name, conn, *args)
45
+ def self.read_sql_table(table_name, conn=nil, *args)
46
+ if conn.nil? && IO.is_activerecord_model?(table_name)
47
+ unless table_name.table_name
48
+ raise ArgumentError, "The given model does not have its table_name"
49
+ end
50
+ table_name, conn = table_name.table_name, table_name.connection
51
+ end
52
+
53
+ unless conn
54
+ raise ArgumentError, "wrong number of arguments (given 1, expected 2+)"
55
+ end
56
+
42
57
  if IO.is_activerecord_datasource?(conn)
43
58
  require 'pandas/io/active_record'
44
59
  return IO::Helpers.read_sql_table_from_active_record(table_name, conn, *args)
@@ -2,6 +2,12 @@ require 'pandas'
2
2
 
3
3
  module Pandas
4
4
  module IO
5
+ def self.is_activerecord_model?(obj)
6
+ return false unless defined?(::ActiveRecord)
7
+ return true if obj.is_a?(Class) && obj < ActiveRecord::Base
8
+ false
9
+ end
10
+
5
11
  def self.is_activerecord_datasource?(obj)
6
12
  return false unless defined?(::ActiveRecord)
7
13
  return true if obj.is_a?(::ActiveRecord::ConnectionAdapters::AbstractAdapter)
@@ -1 +1 @@
1
- PANDAS_VERSION = "0.2.0"
1
+ PANDAS_VERSION = "0.3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-11 00:00:00.000000000 Z
11
+ date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pycall
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.6.12
142
+ rubygems_version: 2.6.13
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Pandas wrapper for Ruby