@@ -123,28 +123,55 @@ def astype(self, dtype):
123
123
124
124
Create a series of type ``Int64``:
125
125
126
- >>> ser = bpd.Series([1, 2 ], dtype='Int64')
126
+ >>> ser = bpd.Series([2023010000246789, 1624123244123101, 1054834234120101 ], dtype='Int64')
127
127
>>> ser
128
- 0 1
129
- 1 2
128
+ 0 2023010000246789
129
+ 1 1624123244123101
130
+ 2 1054834234120101
130
131
dtype: Int64
131
132
132
133
Convert to ``Float64`` type:
133
134
134
135
>>> ser.astype('Float64')
135
- 0 1.0
136
- 1 2.0
136
+ 0 2023010000246789.0
137
+ 1 1624123244123101.0
138
+ 2 1054834234120101.0
137
139
dtype: Float64
138
140
141
+ Convert to ``pd.ArrowDtype(pa.timestamp("us", tz="UTC"))`` type:
142
+
143
+ >>> ser.astype("timestamp[us, tz=UTC][pyarrow]")
144
+ 0 2034-02-08 11:13:20.246789+00:00
145
+ 1 2021-06-19 17:20:44.123101+00:00
146
+ 2 2003-06-05 17:30:34.120101+00:00
147
+ dtype: timestamp[us, tz=UTC][pyarrow]
148
+
149
+ Note that this is equivalent of using ``to_datetime`` with ``unit='us'``:
150
+
151
+ >>> bpd.to_datetime(ser, unit='us', utc=True)
152
+ 0 2034-02-08 11:13:20.246789+00:00
153
+ 1 2021-06-19 17:20:44.123101+00:00
154
+ 2 2003-06-05 17:30:34.120101+00:00
155
+ dtype: timestamp[us, tz=UTC][pyarrow]
156
+
157
+ Convert ``pd.ArrowDtype(pa.timestamp("us", tz="UTC"))`` type to ``Int64`` type:
158
+
159
+ >>> timestamp_ser = ser.astype("timestamp[us, tz=UTC][pyarrow]")
160
+ >>> timestamp_ser.astype('Int64')
161
+ 0 2023010000246789
162
+ 1 1624123244123101
163
+ 2 1054834234120101
164
+ dtype: Int64
165
+
139
166
Args:
140
167
dtype (str or pandas.ExtensionDtype):
141
- A dtype supported by BigQuery DataFrame include 'boolean', 'Float64', 'Int64',
142
- ' string', 'string[pyarrow]', 'timestamp[us, tz=UTC][pyarrow]',
143
- 'timestamp[us] [pyarrow]', 'date32[day] [pyarrow]', 'time64[us] [pyarrow]'
144
- A pandas.ExtensionDtype include pandas.BooleanDtype(), pandas.Float64Dtype(),
145
- pandas.Int64Dtype(), pandas.StringDtype(storage="pyarrow"),
146
- pd.ArrowDtype(pa.date32()), pd.ArrowDtype(pa.time64("us")),
147
- pd.ArrowDtype(pa.timestamp("us")), pd.ArrowDtype(pa.timestamp("us", tz="UTC")).
168
+ A dtype supported by BigQuery DataFrame include `` 'boolean'``, `` 'Float64'``, `` 'Int64'`` ,
169
+ ``'int64[pyarrow]'``, ``' string'``, `` 'string[pyarrow]'``, `` 'timestamp[us, tz=UTC][pyarrow]'`` ,
170
+ `` 'timestamp\ [us\]\ [pyarrow\]'``, `` 'date32\ [day\]\ [pyarrow\]'``, `` 'time64\ [us\]\ [pyarrow\]'``.
171
+ A pandas.ExtensionDtype include `` pandas.BooleanDtype()``, `` pandas.Float64Dtype()`` ,
172
+ `` pandas.Int64Dtype()``, `` pandas.StringDtype(storage="pyarrow")`` ,
173
+ `` pd.ArrowDtype(pa.date32())``, `` pd.ArrowDtype(pa.time64("us"))`` ,
174
+ `` pd.ArrowDtype(pa.timestamp("us"))``, `` pd.ArrowDtype(pa.timestamp("us", tz="UTC"))`` .
148
175
149
176
Returns:
150
177
same type as caller
0 commit comments