id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
pandas_user_guide/vectorizationinpanda_120_0.txt | About | |
pandas_user_guide/pandas_user_guide_27_76.txt | est.feather")
def test_pickle_write(df):
df.to_pickle("test.pkl")
def test_pickle_read():
pd.read_pickle("test.pkl")
def test_pickle_write_compress(df):
df.to_pickle("test.pkl.compress", compression="xz")
def test_pickle_read_compress():
... | |
pandas_user_guide/pandas_user_guide_4_8.txt | 40]: df2.groupby(["cats", "B"], observed=False).mean()
Out[140]:
values
cats B
a c 1.0
d 2.0
b c 3.0
d 4.0
c c NaN
d NaN
Pivot tables:
In [141]: raw_cat = pd.Categorical(["a", "a", "b", "b"], catego... | |
pandas_user_guide/pandas_user_guide_27_63.txt | 601]:
A
0 foo
1 bar
2 nan
In [602]: store.append("dfss", dfss)
In [603]: store.select("dfss")
Out[603]:
A
0 foo
1 bar
2 NaN
# here you need to specify a different nan rep
In [604]: store.append("dfss2", dfss, nan_rep="_nan_")
... | |
pandas_user_guide/pandas_user_guide_6_4.txt | ored elements in COOrdinate format>
In [61]: A.todense()
Out[61]:
matrix([[0., 0., 1., 2.],
[3., 0., 0., 0.],
[0., 0., 0., 0.]])
The default behaviour (with ` dense_index=False ` ) simply returns a [ `
Series ` ](../reference/api/pandas.Series.html#pandas.Series "pandas... | |
pandas_user_guide/howtospeeduppythonpa_144_0.txt | %%timeit
df = get_data()
df['reward'] = df['bad_karma']
df.loc[((df['percentage_productive'] >= 0.5) &
(df['time_at_work'] >= 2)) |
(df['age'] >= 65), 'reward'] = df['favorite_treat'] | |
pandas_user_guide/howtospeeduppythonpa_46_0.txt | 404 ms ± 18.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) | |
pandas_user_guide/howtospeeduppythonpa_175_0.txt | March 29, 2024 15 min read ](/blog/deep-learning/diffusion-and-denoising-
explaining-text-to-image-generative-ai) | |
pandas_user_guide/vectorizationinpanda_5_0.txt | [
](https://medium.com/search?source=---two_column_layout_nav----------------------------------) | |
pandas_user_guide/vectorizationinpanda_19_0.txt | \-- | |
pandas_user_guide/tutorialbasicvectori_58_0.txt | This code compares the execution times of vectorization, iterrows(), and
apply() for adding two columns in a large DataFrame. If you run those code on
Google Colab, you should get similar output with me. | |
pandas_user_guide/pandas_user_guide_20_11.txt | var2
0 a 1
0 b 1
0 c 1
1 d 2
1 e 2
1 f 2
## [ ` crosstab() ` ](../reference/api/pandas.crosstab.html#pandas.crosstab
"pandas.crosstab") #
Use [ ` crosstab() ` ](../reference/api/pandas.crosstab.html#pandas.crosstab
"pandas.crosstab") to comput... | |
pandas_user_guide/pandas_user_guide_5_15.txt | aFrame.agg") .
We will use a similar starting frame from above:
In [161]: tsdf = pd.DataFrame(
.....: np.random.randn(10, 3),
.....: columns=["A", "B", "C"],
.....: index=pd.date_range("1/1/2000", periods=10),
.....: )
.....:
In [162]: tsdf.iloc[3... | |
pandas_user_guide/tutorialbasicvectori_53_0.txt | ## 4\. Using apply() | |
pandas_user_guide/howtospeeduppythonpa_164_0.txt | [  | |
pandas_user_guide/pandas_user_guide_14_10.txt | aFrame({"a": [0, 1, 1], "b": [1, 1, 0]}, dtype=bool)
In [103]: df1 & df2
Out[103]:
a b
0 False False
1 False True
2 True False
In [104]: df1 | df2
Out[104]:
a b
0 True True
1 True True
2 True True
In [105]: df1 ^ df... | |
pandas_user_guide/howtospeeduppythonpa_110_0.txt | ## What is Pandas for Python? | |
pandas_user_guide/pandas_user_guide_25_11.txt | 5 ... 127.0 14.0 1.0 1.0 15.0 18.0
DET 5 301 1062 162 283 54 ... 176.0 3.0 10.0 4.0 8.0 28.0
HOU 4 311 926 109 218 47 ... 212.0 3.0 9.0 16.0 6.0 17.0
LAN 11 413 1021 153 293 61 ... 141.0 8.0 9.0 3.0 8.0 29.0
... | |
pandas_user_guide/pandas_user_guide_14_12.txt | ), int64(11), object(3)
memory usage: 18.1+ KB
However, using [ ` DataFrame.to_string() `
](../reference/api/pandas.DataFrame.to_string.html#pandas.DataFrame.to_string
"pandas.DataFrame.to_string") will return a string representation of the [ `
DataFrame ` ](../reference/api/pandas.DataFrame.html#pandas.Dat... | |
pandas_user_guide/howtospeeduppythonpa_42_0.txt | ### Apply | |
pandas_user_guide/tutorialbasicvectori_54_0.txt | The apply() method allows you to apply a function to each element of a Series
or DataFrame. It can be more efficient than iterrows(), but it may still be
slower than vectorization. | |
pandas_user_guide/howtospeeduppythonpa_102_0.txt | Deep Learning | |
pandas_user_guide/pandasvectorization_41_0.txt |
Please enable JavaScript to view the [ comments powered by Disqus.
](https://disqus.com/?ref_noscript) | |
pandas_user_guide/pandas_user_guide_25_20.txt | een', 'green', 'green', 'green', 'green',
'green', 'green'], dtype='<U5')
In [246]: foods
Out[246]:
array(['ham', 'ham', 'eggs', 'eggs', 'eggs', 'ham', 'ham', 'eggs', 'eggs',
'eggs'], dtype='<U4')
In [247]: index = pd.MultiIndex.from_arrays([colors, foods], names=['color... | |
pandas_user_guide/tutorialbasicvectori_21_0.txt | [ Join now ](https://www.linkedin.com/signup/cold-
join?session_redirect=%2Fpulse%2Ftutorial-basic-vectorization-pandas-iterrows-
apply-duc-lai-trung-minh-75d4c%2F&trk=article-ssr-frontend-pulse_nav-header-
join) [ Sign in
](https://www.linkedin.com/uas/login?session_redirect=%2Fpulse%2Ftutorial-
basic-vectorization-pa... | |
pandas_user_guide/howtospeeduppythonpa_99_0.txt | ### Our Goal | |
pandas_user_guide/pandas_user_guide_2_8.txt | ...
'2011-12-09', '2011-12-12', '2011-12-14', '2011-12-16',
'2011-12-19', '2011-12-21', '2011-12-23', '2011-12-26',
'2011-12-28', '2011-12-30'],
dtype='datetime64[ns]', length=154, freq='C')
In [92]: pd.bdate_range(start, end, freq... | |
pandas_user_guide/vectorizationinpanda_96_0.txt | [ Pandas ](https://medium.com/tag/pandas?source=post_page-----3a4fda08a184
---------------pandas-----------------) | |
pandas_user_guide/howtospeeduppythonpa_122_0.txt | def reward_calc(row):
if row['age'] >= 65:
return row ['favorite_treat']
if (row['time_at_work'] >= 2) & (row['percentage_productive'] >= 0.5):
return row ['favorite_treat']
return row['bad_karma'] | |
pandas_user_guide/vectorizationinpanda_44_0.txt | # Creating a new column 'D' based on a condition in column 'A'
df['D'] = df['A'].apply(lambda x: 'Even' if x % 2 == 0 else 'Odd') | |
pandas_user_guide/pandas_user_guide_11_5.txt | True})
201 ms ± 2.97 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
### Custom Function Examples #
A custom Python function decorated with ` @jit ` can be used with pandas
objects by passing their NumPy array representations with [ `
Series.to_numpy() `
](../reference/api/pandas.Series.to_numpy.... | |
pandas_user_guide/tutorialbasicvectori_30_0.txt | Published Oct 29, 2023 | |
pandas_user_guide/howtospeeduppythonpa_137_0.txt | The ‘apply' function effectively does the same thing as the loop. It will
create a new column titled reward and apply the calculation function every 1
row as defined by 'axis=1’. The 'Apply' function is a faster way to run a loop
to your dataset. | |
pandas_user_guide/pandas_user_guide_2_1.txt | -08:00', '2017-12-31 17:00:00-08:00',
'2017-12-31 18:00:00-08:00'],
dtype='datetime64[ns, US/Pacific]', freq='h')
Resampling or converting a time series to a particular frequency
In [9]: idx = pd.date_range("2018-01-01", periods=5, freq="h")
In [10]: ts... | |
pandas_user_guide/pandas_user_guide_26_6.txt | gation is a GroupBy operation that reduces the dimension of the
grouping object. The result of an aggregation is, or at least is treated as, a
scalar value for each column in a group. For example, producing the sum of
each column in a group of values.
In [79]: animals = pd.DataFrame(
....: {
... | |
pandas_user_guide/pandas_user_guide_25_4.txt | one
0 1.0
1 2.0
2 3.0
## Slicing ranges #
The most robust and consistent way of slicing ranges along arbitrary axes is
described in the Selection by Position section detailing the ` .iloc `
method. For now, we explain the semantics of slicing using the ` [] `
operator.
With Series, the sy... | |
pandas_user_guide/vectorizationinpanda_25_0.txt | Vectorization is the process of applying operations to entire arrays or Series
of data, instead of iterating through each element individually. In Pandas,
this means that you can perform operations on entire columns or Series without
writing explicit loops. This highly efficient approach leverages optimized
libraries u... | |
pandas_user_guide/howtospeeduppythonpa_184_0.txt |  | |
pandas_user_guide/howtospeeduppythonpa_111_0.txt | [ Pandas ](https://pandas.pydata.org/docs/) is an essential and popular open-
source data manipulation and data analysis library for the Python programming
language. Pandas is widely used in various fields such as finance, economics,
social sciences, and engineering. It is beneficial for data cleaning,
preparation, and... | |
pandas_user_guide/howtospeeduppythonpa_157_0.txt | Training AI models on massive datasets can be accelerated exponentially with
the right system. It's not just a high-performance computer, but a tool to
propel and accelerate your research. | |
pandas_user_guide/pandas_user_guide_14_1.txt |
In [3]: s = pd.Series(np.random.randn(5), index=["a", "b", "c", "d", "e"])
In [4]: s
Out[4]:
a 0.469112
b -0.282863
c -1.509059
d -1.135632
e 1.212112
dtype: float64
In [5]: s.index
Out[5]: Index(['a', 'b', 'c', 'd', 'e'], dtype='object')
I... | |
pandas_user_guide/pandas_user_guide_16_3.txt | and then disallow
duplicates going forward, to ensure that your data pipeline doesnât
introduce duplicates.
>>> raw = pd.read_csv("...")
>>> deduplicated = raw.groupby(level=0).first() # remove duplicates
>>> deduplicated.flags.allows_duplicate_labels = False # disallow going forward
S... | |
pandas_user_guide/pandas_user_guide_27_60.txt | -1.726280
2000-01-06 0.266901 -0.036854
2000-01-07 -0.517871 -0.990317
2000-01-08 -0.231342 0.557402
In [584]: store.select("df2_mt")
Out[584]:
C D E F foo
2000-01-01 -2.502042 0.668149 0.460708 1.834518 bar
2000-01-02 0.130441 -0... | |
pandas_user_guide/howtospeeduppythonpa_53_0.txt | That is extremely fast. **40x faster than the Apply** and approximately **360x
faster than Looping…** | |
pandas_user_guide/tutorialbasicvectori_65_0.txt | [ Like ](https://www.linkedin.com/signup/cold-
join?session_redirect=%2Fpulse%2Ftutorial-basic-vectorization-pandas-iterrows-
apply-duc-lai-trung-minh-75d4c%2F&trk=article-ssr-frontend-pulse_x-social-
details_like-toggle_like-cta) | |
pandas_user_guide/pandas_user_guide_2_16.txt | 23:30")).normalize()
Out[166]: Timestamp('2014-01-02 00:00:00')
### Parametric offsets #
Some of the offsets can be âparameterizedâ when created to result in
different behaviors. For example, the ` Week ` offset for generating weekly
data accepts a ` weekday ` parameter which results in the generated... | |
pandas_user_guide/vectorizationinpanda_65_0.txt | Output:
[ 7 9 11 13 15] | |
pandas_user_guide/vectorizationinpanda_109_0.txt | [ 427 Followers ](https://gaurav-adarshi.medium.com/followers?source=post_page
-----3a4fda08a184--------------------------------) | |
pandas_user_guide/howtospeeduppythonpa_185_0.txt | [ ](https://www.linkedin.com/company/exxactcorp) [
](https://twitter.com/exxactcorp) [ ](https://www.facebook.com/exxactcorp) | |
pandas_user_guide/pandas_user_guide_2_35.txt | the same time zone input. A [ ` DatetimeIndex `
](../reference/api/pandas.DatetimeIndex.html#pandas.DatetimeIndex
"pandas.DatetimeIndex") can hold a collection of [ ` Timestamp `
](../reference/api/pandas.Timestamp.html#pandas.Timestamp "pandas.Timestamp")
objects that may have different UTC offsets and cannot be suc... | |
pandas_user_guide/howtospeeduppythonpa_82_0.txt | machine learning | |
pandas_user_guide/howtospeeduppythonpa_58_0.txt | ## How to Vectorize your Pandas Code | |
pandas_user_guide/pandas_user_guide_5_10.txt | e ` /
` exclude ` arguments. The special value ` all ` can also be used:
In [105]: frame.describe(include=["object"])
Out[105]:
a
count 4
unique 2
top Yes
freq 2
In [106]: frame.describe(include=["number"])
Out[106]:
b
... | |
pandas_user_guide/howtospeeduppythonpa_151_0.txt | Vectorized operations, on the other hand, are implemented in Cython (Python in
C or C++) and utilize the CPU's vector processing capabilities, which can
perform multiple operations at once, further increasing performance by
calculating multiple parameters at the same time. Vectorized operations also
avoid the overhead ... | |
pandas_user_guide/howtospeeduppythonpa_67_0.txt | #### Related Posts | |
pandas_user_guide/pandas_user_guide_27_23.txt | 15
y 16
z 17
Name: D, dtype: int64
**Column oriented** (the default for ` DataFrame ` ) serializes the data as
nested JSON objects with column labels acting as the primary index:
In [237]: dfjo.to_json(orient="columns")
Out[237]: '{"A":{"x":1,"y":2,"z":3},"B":{"x":4,"y":5,"... | |
pandas_user_guide/pandas_user_guide_12_2.txt |
In [24]: df
Out[24]:
foo bar
0 5 4
1 2 5
2 3 6
**Constructors now copy NumPy arrays by default**
The Series and DataFrame constructors will now copy NumPy array by default
when not otherwise specified. This was changed to avoid mutating a pandas
object when the... | |
pandas_user_guide/howtospeeduppythonpa_108_0.txt | ## How to Speed Up Pandas Code - Vectorization | |
pandas_user_guide/vectorizationinpanda_112_0.txt | ](https://python.plainenglish.io/?source=post_page-----
3a4fda08a184--------------------------------) | |
pandas_user_guide/pandas_user_guide_13_8.txt | lse
` , we have \\(y_0 = x_0\\) and \\(y_t = \alpha x_t + (1 - \alpha)
y_{t-1}\\) . Therefore, there is an assumption that \\(x_0\\) is not an
ordinary value but rather an exponentially weighted moment of the infinite
series up to that point.
One must have \\(0 < \alpha \leq 1\\) , and while it is possible to ... | |
pandas_user_guide/pandas_user_guide_21_0.txt | Skip to main content
__ Back to top
__ ` Ctrl ` \+ ` K `
[  ](../index.html)
Site Navigation
* [ Getting started ](../getting_started/index.html)
* [ User Guide ](index.html)
* [ API reference ](../reference/index.html)
* [ Development ](../develop... | |
pandas_user_guide/vectorizationinpanda_127_0.txt | ](https://policy.medium.com/medium-privacy-
policy-f03bf92035c9?source=post_page-----
3a4fda08a184--------------------------------) | |
pandas_user_guide/vectorizationinpanda_86_0.txt | ### Vectorization is the process of applying operations to entire arrays or
Series of data, instead of iterating through… | |
pandas_user_guide/pandas_user_guide_25_5.txt | ble_usage(key,
> maybe_callable)
> -> 1191 return self._getitem_axis(maybe_callable, axis=axis)
>
> File ~/work/pandas/pandas/pandas/core/indexing.py:1411, in
> _LocIndexer._getitem_axis(self, key, axis)
> 1409 if isinstance(key, slice):
> 1410 self._validate_key(key, axis)
> -> 1411 ... | |
pandas_user_guide/tutorialbasicvectori_22_0.txt | ` ` ` ` ` ` ` ` | |
pandas_user_guide/howtospeeduppythonpa_28_0.txt | def reward_calc(row):
if row['age'] >= 65:
return row ['favorite_treat']
if (row['time_at_work'] >= 2) & (row['percentage_productive'] >= 0.5):
return row ['favorite_treat']
return row['bad_karma'] | |
pandas_user_guide/tutorialbasicvectori_2_0.txt | By clicking Continue to join or sign in, you agree to LinkedIn’s [ User
Agreement ](/legal/user-agreement?trk=linkedin-tc_auth-button_user-agreement)
, [ Privacy Policy ](/legal/privacy-policy?trk=linkedin-tc_auth-
button_privacy-policy) , and [ Cookie Policy ](/legal/cookie-
policy?trk=linkedin-tc_auth-button_cookie-p... | |
pandas_user_guide/pandasvectorization_20_0.txt | # DataFrame
df = pd.DataFrame(d, columns=col, index=index) | |
pandas_user_guide/pandas_user_guide_13_9.txt | Exponentially weighted window
[ __ Show Source ](../_sources/user_guide/window.rst.txt)
© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .
Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.
Built with the [ PyData Sphinx Theme ](https://pydata... | |
pandas_user_guide/vectorizationinpanda_110_0.txt | · Writer for | |
pandas_user_guide/tutorialbasicvectori_44_0.txt | Pandas is a powerful library for data manipulation in Python. It provides
various ways to work with data, and choosing the right method can
significantly impact the performance of your code. In this tutorial, we’ll
focus on vectorization and compare it with two other common techniques:
iterrows() and apply(). | |
pandas_user_guide/pandas_user_guide_9_8.txt | lue).
In [79]: df.xs("one", level="second", axis=1, drop_level=True)
Out[79]:
first bar baz foo qux
A 0.895717 -1.206412 1.431256 -1.170299
B 0.410835 0.132003 -0.076467 1.130127
C -1.413681 1.024180 0.875906 0.974466
### Advanced re... | |
pandas_user_guide/howtospeeduppythonpa_65_0.txt | ### Sign up for our newsletter. | |
pandas_user_guide/pandas_user_guide_5_20.txt | d -1.425662
e 1.114285
dtype: float64)
In [222]: s1.align(s2, join="inner")
Out[222]:
(b -1.692424
c -0.303893
d -1.425662
dtype: float64,
b -1.692424
c -0.303893
d -1.425662
dtype: float64)
In [223]: s1.align(s2, join="left")
... | |
pandas_user_guide/pandas_user_guide_11_0.txt | Skip to main content
__ Back to top
__ ` Ctrl ` \+ ` K `
[  ](../index.html)
Site Navigation
* [ Getting started ](../getting_started/index.html)
* [ User Guide ](index.html)
* [ API reference ](../reference/index.html)
* [ Development ](../develop... | |
pandas_user_guide/pandas_user_guide_27_45.txt | ay dtype is not guaranteed. For instance, a
column of integers with missing values cannot be transformed to an array with
integer dtype, because NaN is strictly a float. You can manually mask missing
data to recover integer dtype:
def cfun(x):
return int(x) if x else -1
pd.read_exce... | |
pandas_user_guide/pandas_user_guide_27_8.txt | In [56]: pd.read_csv(StringIO(data), names=["foo", "bar", "baz"], header=None)
Out[56]:
foo bar baz
0 a b c
1 1 2 3
2 4 5 6
3 7 8 9
If the header is in a row other than the first, pass the row number to `
header ` . This will skip the preceding rows:
... | |
pandas_user_guide/tutorialbasicvectori_20_0.txt | * [ Articles ](https://www.linkedin.com/pulse/topics/home/?trk=article-ssr-frontend-pulse_guest_nav_menu_articles)
* [ People ](https://www.linkedin.com/pub/dir/+/+?trk=article-ssr-frontend-pulse_guest_nav_menu_people)
* [ Learning ](https://www.linkedin.com/learning/search?trk=article-ssr-frontend-pulse_guest_nav_m... | |
pandas_user_guide/vectorizationinpanda_30_0.txt | data = {'A': [1, 2, 3], 'B': [4, 5, 6]}
df = pd.DataFrame(data)
# Using vectorization to add columns 'A' and 'B'
df['C'] = df['A'] + df['B']
print(df['C']) | |
pandas_user_guide/howtospeeduppythonpa_109_0.txt | If we want our deep learning models to train on a dataset, we have to optimize
our code to parse through that data quickly. We want to read our data tables
as fast as possible using an optimized way to write our code. Even the
smallest performance gain exponentially improves performance over tens of
thousands of data p... | |
pandas_user_guide/tutorialbasicvectori_8_0.txt | ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` | |
pandas_user_guide/pandasvectorization_23_0.txt | | one | two
---|---|---
a | 1 | 1
b | 2 | 2
c | 3 | 3
d | 4 | 4 | |
pandas_user_guide/tutorialbasicvectori_3_0.txt | ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` | |
pandas_user_guide/howtospeeduppythonpa_147_0.txt | That is extremely fast. **40x faster than the Apply** and approximately **360x
faster than Looping…** | |
pandas_user_guide/pandas_user_guide_27_66.txt | t in the target table.
If you want to omit a dataframeâs indexes when writing, pass ` index=False
` to [ ` to_parquet() `
](../reference/api/pandas.DataFrame.to_parquet.html#pandas.DataFrame.to_parquet
"pandas.DataFrame.to_parquet") :
In [628]: df.to_parquet("test.parquet", index=False)
This cr... | |
pandas_user_guide/vectorizationinpanda_79_0.txt | Make sure you have NumPy installed ( ` pip install numpy ` ) before running
the code. | |
pandas_user_guide/pandas_user_guide_27_50.txt | "file.h5", "df_with_missing")
Out[476]:
col1 col2
0 0.0 1.0
1 NaN NaN
2 2.0 NaN
In [477]: df_with_missing.to_hdf(
.....: "file.h5", key="df_with_missing", format="table", mode="w", dropna=True
.....: )
.....:
In [478]: pd.read_hdf("file.h5... | |
pandas_user_guide/howtospeeduppythonpa_133_0.txt | This is what it returned: | |
pandas_user_guide/pandas_user_guide_26_2.txt | yntactic sugar for ` df.groupby(df['A']) ` .
If we also have a MultiIndex on columns ` A ` and ` B ` , we can group by
all the columns except the one we specify:
In [10]: df2 = df.set_index(["A", "B"])
In [11]: grouped = df2.groupby(level=df2.index.names.difference(["B"]))
In [12]: ... | |
pandas_user_guide/pandas_user_guide_5_0.txt | Skip to main content
__ Back to top
__ ` Ctrl ` \+ ` K `
[  ](../index.html)
Site Navigation
* [ Getting started ](../getting_started/index.html)
* [ User Guide ](index.html)
* [ API reference ](../reference/index.html)
* [ Development ](../develop... | |
pandas_user_guide/pandas_user_guide_27_57.txt | trepack-sortby-
needs-full-index) for how to create a completely-sorted-index (CSI) on an
existing store.
#### Query via data columns #
You can designate (and index) certain columns that you want to be able to
perform queries (other than the ` indexable ` columns, which you can always
query). For instance say you ... | |
pandas_user_guide/pandas_user_guide_2_30.txt | 0', 'h')
In [365]: p + np.timedelta64(7200, "s")
Out[365]: Period('2014-07-01 11:00', 'h')
In [366]: p + pd.offsets.Minute(5)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
... | |
pandas_user_guide/howtospeeduppythonpa_25_0.txt | def get_data(size = 10_000):
df = pd.DataFrame()
df['age'] = np.random.randint(0, 100, size)
df['time_at_work'] = np.random.randint(0,8,size)
df['percentage_productive'] = np.random.rand(size)
df['favorite_treat'] = np.random.choice(['ice_cream', 'boba', 'cookie'], size)
df['bad_karma'] = np.random.choice(['stub_toe', ... | |
pandas_user_guide/vectorizationinpanda_63_0.txt | import numpy as np | |
pandas_user_guide/howtospeeduppythonpa_124_0.txt |  | |
pandas_user_guide/howtospeeduppythonpa_77_0.txt | ##### Deep Learning | |
pandas_user_guide/pandas_user_guide_27_26.txt | son("test.json", dtype={"A": "float32", "bools": "int8"}).dtypes
Out[266]:
A float32
B float64
date int64
ints int64
bools int8
dtype: object
Preserve string indices:
In [267]: from io import StringIO
In [268]: si = pd.DataFrame(... | |
pandas_user_guide/pandasvectorization_21_0.txt |
In [56]: | |
pandas_user_guide/howtospeeduppythonpa_70_0.txt | #### Managing Python Dependencies with Poetry vs Conda & Pip | |
pandas_user_guide/pandas_user_guide_27_44.txt | ex ` index without names:
In [424]: df = pd.DataFrame(
.....: {"a": [1, 2, 3, 4], "b": [5, 6, 7, 8]},
.....: index=pd.MultiIndex.from_product([["a", "b"], ["c", "d"]]),
.....: )
.....:
In [425]: df.to_excel("path_to_file.xlsx")
In [426]: df = pd.rea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.