id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
pandas_user_guide/howtospeeduppythonpa_159_0.txt | #### Related Posts | |
pandas_user_guide/pandas_user_guide_2_3.txt | .g. strings,
epochs, or a mixture, you can use the ` to_datetime ` function. When passed a
` Series ` , this returns a ` Series ` (with the same index), while a list-
like is converted to a ` DatetimeIndex ` :
In [44]: pd.to_datetime(pd.Series(["Jul 31, 2009", "Jan 10, 2010", None]))
Out[44]:
... | |
pandas_user_guide/pandas_user_guide_25_10.txt | 1691 with suppress(IndexingError):
1692 return self._getitem_lowerdim(tup)
File ~/work/pandas/pandas/pandas/core/indexing.py:966, in _LocationIndexer._validate_tuple_indexer(self, key)
964 for i, k in enumerate(key):
965 try:
--> 966 self._validate_key(k, ... | |
pandas_user_guide/howtospeeduppythonpa_119_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_119_0.txt | ](https://medium.statuspage.io/?source=post_page-----
3a4fda08a184--------------------------------) | |
pandas_user_guide/pandasvectorization_12_0.txt | # columns
columns = ['one', 'two'] | |
pandas_user_guide/howtospeeduppythonpa_152_0.txt | ## How to Vectorize your Pandas Code | |
pandas_user_guide/pandas_user_guide_20_7.txt | -1e9)
Out[46]:
exp B
animal dog cat
second one two one two
first
bar -1.110336e+00 6.8773... | |
pandas_user_guide/pandas_user_guide_9_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_23_6.txt | 0.25
1 2.1 NaN
2 NaN NaN
3 4.7 4.00
4 5.6 12.20
5 6.8 14.40
In [105]: df.interpolate()
Out[105]:
A B
0 1.0 0.25
1 2.1 1.50
2 3.4 2.75
3 4.7 4.00
4 5.6 12.20
5 6.8 14.40
In [106]: idx = pd.date_range("2020-0... | |
pandas_user_guide/pandas_user_guide_18_10.txt | / 10000,
.....: index=pd.date_range("2001-01-01", periods=2000),
.....: columns=["A", "B"],
.....: )
.....:
In [164]: df
Out[164]:
A B
2001-01-01 -0.000144 -0.000141
2001-01-02 0.000161 0.000102
2001-01-03 0.000057 0.0000... | |
pandas_user_guide/tutorialbasicvectori_23_0.txt | ![Tutorial \[Basic\]: 700x speed improvement on Pandas with Vectorization vs.
Iterrows/Apply](https://media.licdn.com/dms/image/D5612AQHihqIV5cFk5g/article-
cover_image-
shrink_600_2000/0/1698593684831?e=2147483647&v=beta&t=1MWEAnkzaV0mv1B_Gsv9qC1HZv91jHZyyHBv7uEnQNI) | |
pandas_user_guide/vectorizationinpanda_90_0.txt | In conclusion, vectorization in Pandas and libraries like NumPy is a powerful
technique for enhancing the efficiency of data manipulation tasks in Python.
It allows you to perform operations on entire columns or collections of data
in a highly optimized manner, leading to faster and more concise code. Whether
you’re de... | |
pandas_user_guide/pandas_user_guide_25_12.txt | reindex_axes(self, axes, level, limit, tolerance, method, fill_value, copy)
5627 continue
5629 ax = self._get_axis(a)
-> 5630 new_index, indexer = ax.reindex(
5631 labels, level=level, limit=limit, tolerance=tolerance, method=method
5632 )
5634 axis = self._get_axis_number... | |
pandas_user_guide/pandas_user_guide_27_73.txt | hat
is outside of the permitted range in Stata for a particular data type will
retype the variable to the next larger size. For example, ` int8 ` values are
restricted to lie between -127 and 100 in Stata, and so variables with values
above 100 will trigger a conversion to ` int16 ` . ` nan ` values in
floating poin... | |
pandas_user_guide/pandas_user_guide_21_1.txt | .array([1, 2, np.nan, None, pd.NA], dtype="Int64")
Out[4]:
<IntegerArray>
[1, 2, <NA>, <NA>, <NA>]
Length: 5, dtype: Int64
This array can be stored in a [ ` DataFrame `
](../reference/api/pandas.DataFrame.html#pandas.DataFrame "pandas.DataFrame")
or [ ` Series ` ](../reference/api/pandas.Series... | |
pandas_user_guide/howtospeeduppythonpa_78_0.txt | #### SXM vs PCIe: GPUs Best for Training LLMs like GPT-4 | |
pandas_user_guide/pandas_user_guide_23_7.txt | 14.40
In [125]: df.interpolate(method="barycentric")
Out[125]:
A B
0 1.00 0.250
1 2.10 -7.660
2 3.53 -4.515
3 4.70 4.000
4 5.60 12.200
5 6.80 14.400
In [126]: df.interpolate(method="pchip")
Out[126]:
A B
0 1.000... | |
pandas_user_guide/pandas_user_guide_14_13.txt | ser_name/storage/folder_01/filename_01
1 filename_02 media/user_name/storage/folder_02/filename_02
You can also disable this feature via the ` expand_frame_repr ` option. This
will print the table in one block.
### DataFrame column attribute access and IPython completion #
If a [ ` DataFrame `
](../re... | |
pandas_user_guide/pandas_user_guide_5_34.txt | 09]:
0 1
0 2016-07-09 2016-03-02 00:00:00
1 2016-07-09 2016-03-02 00:00:00
In [410]: df.apply(pd.to_datetime)
Out[410]:
0 1
0 2016-07-09 2016-03-02
1 2016-07-09 2016-03-02
In [411]: df = pd.DataFrame([["1.1", 2, 3]] *... | |
pandas_user_guide/howtospeeduppythonpa_116_0.txt | We are first going to import our frameworks and generate some random code
before we start: | |
pandas_user_guide/pandas_user_guide_0_1.txt | A ` | ` NA `
` NA | NA ` | ` NA `
` True ^ True ` | ` False `
` True ^ False ` | ` True `
` True ^ NA ` | ` NA `
` False ^ False ` | ` False `
` False ^ NA ` | ` NA `
` NA ^ NA ` | ` NA `
When an ` NA ` is present in an operation, the output value is ` NA ` onl... | |
pandas_user_guide/pandas_user_guide_3_11.txt | plot.html#pandas.DataFrame.plot
"pandas.DataFrame.plot") plots all columns:
In [129]: df = pd.DataFrame(
.....: np.random.randn(1000, 4), index=ts.index, columns=["A", "B", "C", "D"]
.....: )
.....:
In [130]: df = df.cumsum()
In [131]: plt.figure();
In... | |
pandas_user_guide/howtospeeduppythonpa_31_0.txt | #### Accelerate Training with an Exxact Multi-GPU Workstation | |
pandas_user_guide/pandas_user_guide_27_77.txt | yArrow Functionality __ ](pyarrow.html "next page")
__ On this page
* CSV & text files
* Parsing options
* Basic
* Column and index locations and names
* General parsing configuration
* NA and missing data handling
* Datetime handling
* Iteration
* Quoting, com... | |
pandas_user_guide/pandas_user_guide_27_7.txt | red) ` .
In [35]: data = "col1,col2,col3\na,b,1\na,b,2\nc,d,3"
In [36]: pd.read_csv(StringIO(data))
Out[36]:
col1 col2 col3
0 a b 1
1 a b 2
2 c d 3
In [37]: pd.read_csv(StringIO(data)).dtypes
Out[37]:
col1 object
col... | |
pandas_user_guide/pandas_user_guide_14_3.txt | return self._values[label]
1227 # Similar to Index.get_value, but we do not fall back to positional
-> 1228 loc = self.index.get_loc(label)
1230 if is_integer(loc):
1231 return self._values[loc]
File ~/work/pandas/pandas/pandas/core/indexes/base.py:3812, in Index.get_loc(self, ke... | |
pandas_user_guide/howtospeeduppythonpa_165_0.txt | ##### Deep Learning | |
pandas_user_guide/pandas_user_guide_3_12.txt | lueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
See [ Comparisons ](basics.html#basics-compare) and [ Gotchas
](gotchas.html#gotchas) for an explanation and what to do.
[ __ previous User Guide ](index.html "previous page") [ next Intro to data
structu... | |
pandas_user_guide/howtospeeduppythonpa_35_0.txt | To time our functions, we will be using a Jupyter Notebook to make it
relatively simple with the magic function %%timeit. There are other ways to
time a function in Python but for demonstration purposes, our Jupyter Notebook
will suffice. We will do a demo run on the same dataset with 3 ways of
calculating and evaluati... | |
pandas_user_guide/vectorizationinpanda_18_0.txt | [
](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Fpython-
in-plain-
english%2F3a4fda08a184&operation=register&redirect=https%3A%2F%2Fpython.plainenglish.io%2Fvectorization-
in-pandas-simplifying-data-
operations-3a4fda08a184&user=Gaurav+Kumar&userId=f319c9e06fc1&source=-----3a4fda08a184
--... | |
pandas_user_guide/pandas_user_guide_4_13.txt | TypeError: data type 'category' not understood
In [249]: dtype = pd.Categorical(["a"]).dtype
In [250]: try:
.....: np.dtype(dtype)
.....: except TypeError as e:
.....: print("TypeError:", str(e))
.....:
TypeError: Cannot interpret 'CategoricalDtype(categories=... | |
pandas_user_guide/pandas_user_guide_23_2.txt | 2
2 <NA>
dtype: Int64
In [23]: s[2]
Out[23]: <NA>
In [24]: s[2] is pd.NA
Out[24]: True
Currently, pandas does not yet use those data types using [ ` NA `
](../reference/api/pandas.NA.html#pandas.NA "pandas.NA") by default a [ `
DataFrame ` ](../reference/api/pandas.Data... | |
pandas_user_guide/vectorizationinpanda_111_0.txt | Python in Plain English | |
pandas_user_guide/tutorialbasicvectori_18_0.txt | New to LinkedIn? [ 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_contextual-
sign-in-modal_join-link) | |
pandas_user_guide/howtospeeduppythonpa_117_0.txt | import pandas as pd
import numpy as np | |
pandas_user_guide/pandas_user_guide_6_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_25_7.txt | c 1.024180
d 0.974466
e 0.545952
f -1.281247
NA values in a boolean array propagate as ` False ` :
In [58]: mask = pd.array([True, False, True, False, pd.NA, False], dtype="boolean")
In [59]: mask
Out[59]:
<BooleanArray>
[True, False, True, False, <NA>, Fal... | |
pandas_user_guide/pandas_user_guide_2_9.txt | onger time series, you can also pass in
the year or year and month as strings:
In [103]: ts["2011"]
Out[103]:
2011-01-31 0.119209
2011-02-28 -1.044236
2011-03-31 -0.861849
2011-04-29 -2.104569
2011-05-31 -0.494929
2011-06-30 1.071804
2011-07-29 0.721555
... | |
pandas_user_guide/pandas_user_guide_4_1.txt | s that this column should be treated as a categorical variable (e.g. to use suitable statistical methods or plot types).
See also the [ API docs on categoricals ](../reference/arrays.html#api-
arrays-categorical) .
## Object creation #
### Series creation #
Categorical ` Series ` or columns in a ` DataFrame ... | |
pandas_user_guide/pandas_user_guide_5_3.txt | ations #
pandas has support for accelerating certain types of binary numerical and
boolean operations using the ` numexpr ` library and the ` bottleneck `
libraries.
These libraries are especially useful when dealing with large data sets, and
provide large speedups. ` numexpr ` uses smart chunking, caching, and
m... | |
pandas_user_guide/pandas_user_guide_2_21.txt |
(B)Q(E)(S)-NOV | quarterly frequency, year ends in November
(B)Y(E)(S)-DEC | annual frequency, anchored end of December. Same as âYEâ
(B)Y(E)(S)-JAN | annual frequency, anchored end of January
(B)Y(E)(S)-FEB | annual frequency, anchored end of February
(B)Y(E)(S)-MAR | annual frequency, an... | |
pandas_user_guide/tutorialbasicvectori_33_0.txt | * [ https://minhduclaitrung.wordpress.com/2023/10/29/tutorial-basic-vectorization-and-pandas-iterrows-apply-and-performance-comparison/ ](https://minhduclaitrung.wordpress.com/2023/10/29/tutorial-basic-vectorization-and-pandas-iterrows-apply-and-performance-comparison/) | |
pandas_user_guide/pandas_user_guide_4_5.txt | ne step (which has some
speed advantage), or simply set the categories to a predefined scale, use `
set_categories() ` .
In [84]: s = pd.Series(["one", "two", "four", "-"], dtype="category")
In [85]: s
Out[85]:
0 one
1 two
2 four
3 -
dtype: category
... | |
pandas_user_guide/vectorizationinpanda_77_0.txt | In this code, we: | |
pandas_user_guide/howtospeeduppythonpa_16_0.txt | ## What is Pandas for Python? | |
pandas_user_guide/vectorizationinpanda_81_0.txt | # How Vectorization Speeds Up Your Code | |
pandas_user_guide/tutorialbasicvectori_59_0.txt | **Based on the result, the performance order is Iterrows (0.74s — slowest),
Apply (0.13s which improves 7x), then _Vectorization (0.001s which improve
740x vs. Iterrows, and 100x vs. Apply)_ . ** | |
pandas_user_guide/tutorialbasicvectori_63_0.txt | ` ` ` ` ` ` ` ` ` ` | |
pandas_user_guide/pandasvectorization_8_0.txt | 1. Lambda Refresher
* lambda functions are small inline functions that are defined on-the-fly in Python
* lambda x: x>= 1 will take an input x and return x>=1, or a boolean that equals True or False.
2. map()
* create a new Series by applying the lambda function to each element
* can only be used on a Series to return ... | |
pandas_user_guide/pandas_user_guide_27_42.txt | l to parse any markup document that is not well-formed or follows XML syntax rules. Do be aware HTML is not an XML document unless it follows XHTML specs. However, other popular markup types including KML, XAML, RSS, MusicML, MathML are compliant [ XML schemas ](https://en.wikipedia.org/wiki/List_of_types_of_XML_schema... | |
pandas_user_guide/pandasvectorization_26_0.txt |
Out[58]: | |
pandas_user_guide/pandas_user_guide_5_2.txt | andas.Timestamp "pandas.Timestamp") objects, each with the correct ` tz `
2. A ` datetime64[ns] ` -dtype [ ` numpy.ndarray ` ](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "\(in NumPy v1.26\)") , where the values have been converted to UTC and the timezone discarded
Timezone... | |
pandas_user_guide/pandas_user_guide_27_49.txt | the excellent [ PyTables
](https://www.pytables.org/) library. See the [ cookbook
](cookbook.html#cookbook-hdf) for some advanced strategies
Warning
pandas uses PyTables for reading and writing HDF5 files, which allows
serializing object-dtype data with pickle. Loading pickled data received from
untrusted sources ca... | |
pandas_user_guide/pandas_user_guide_27_68.txt | ngine() ` function to create
an engine object from database URI. You only need to create the engine once
per database you are connecting to. For more information on ` create_engine()
` and the URI formatting, see the examples below and the SQLAlchemy [
documentation ](https://docs.sqlalchemy.org/en/latest/core/engines... | |
pandas_user_guide/pandas_user_guide_27_24.txt | index and a date column:
In [254]: dfj2 = dfj.copy()
In [255]: dfj2["date"] = pd.Timestamp("20130101")
In [256]: dfj2["ints"] = list(range(5))
In [257]: dfj2["bools"] = True
In [258]: dfj2.index = pd.date_range("20130101", periods=5)
In [259]: dfj2.to_json("t... | |
pandas_user_guide/pandas_user_guide_27_62.txt | k the same as if it was an object array. However, the ` category `
dtyped data is stored in a more efficient manner.
In [586]: dfcat = pd.DataFrame(
.....: {"A": pd.Series(list("aabbcdba")).astype("category"), "B": np.random.randn(8)}
.....: )
.....:
In [587]: dfcat
... | |
pandas_user_guide/pandas_user_guide_24_27.txt | 8 | -0.153565 | -0.460959 | -0.098108 | -1.407930 | -2.487702 | 1.823014 | 0.099873 | -0.517603 | -0.509311 | -1.833175 | -0.900906 | 0.459493 | -0.655440 | 1.466122 | -1.531389 | -0.422106 | 0.421422 | 0.578615 | 0.259795 | 0.018941 | -0.168726 | 1.611107 | -1.586550 | -... | |
pandas_user_guide/pandas_user_guide_24_8.txt | table styles. **Setting classes always overwrites** so
we need to make sure we add the previous classes.
[34]:
s.set_table_styles([ # create internal CSS classes
{'selector': '.border-red', 'props': 'border: 2px dashed red;'},
{'selector': '.border-green', 'props': 'bo... | |
pandas_user_guide/howtospeeduppythonpa_121_0.txt | * If a person’s ‘time_at_work’ is at least 2 hours AND where ‘percentage_productive’ is more than 50%, we return with 'favorite treat'.
* Otherwise, we give them 'bad_karma'.
* If they are over 65 years old, we return with a ‘favorite_treat’ since we our elderly to be happy. | |
pandas_user_guide/vectorizationinpanda_88_0.txt | ](https://www.quizshorts.actopiagames.com/quizstart/6628e8c6935f306b09d1154b?source=post_page
-----3a4fda08a184--------------------------------) | |
pandas_user_guide/howtospeeduppythonpa_41_0.txt | Inexperienced data scientists might see a couple of seconds as no big deal.
But, 3.66 seconds is quite long to run a simple function through a dataset.
Let’s see what the ‘apply’ function can do for us for speed. | |
pandas_user_guide/pandas_user_guide_14_8.txt | ) in a chain of operations. For example, we can limit
the DataFrame to just those observations with a Sepal Length greater than 5,
calculate the ratio, and plot:
In [89]: (
....: iris.query("SepalLength > 5")
....: .assign(
....: SepalRatio=lambda x: x.SepalWidth / x.... | |
pandas_user_guide/pandasvectorization_35_0.txt | a True
b True
c True
d True
Name: one, dtype: bool | |
pandas_user_guide/pandas_user_guide_27_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_14_2.txt | be useful when you need to do some operation without
the index (to disable automatic alignment , for example).
[ ` Series.array `
](../reference/api/pandas.Series.array.html#pandas.Series.array
"pandas.Series.array") will always be an [ ` ExtensionArray `
](../reference/api/pandas.api.extensions.ExtensionArray.htm... | |
pandas_user_guide/pandas_user_guide_5_32.txt | A B C
0 1.047606 0.256090 26.0
1 3.497968 1.426469 86.0
2 -0.150862 -0.416203 46.0
3 0.724370 1.139976 212.0
4 -1.203098 -1.193477 26.0
5 1.346426 0.096706 7.0
6 -0.052599 -1.956850 184.0
7 -0.756495 -0.714337 206.0
In [368]: df3.dtypes
... | |
pandas_user_guide/pandas_user_guide_26_22.txt | Out[258]:
0 0
1 0
2 0
3 1
4 1
5 0
dtype: int64
In [259]: dfg.groupby("A").ngroup(ascending=False)
Out[259]:
0 1
1 1
2 1
3 0
4 0
5 1
dtype: int64
### Plotting #
Groupby also works with some plotting metho... | |
pandas_user_guide/howtospeeduppythonpa_50_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/pandas_user_guide_5_36.txt | numpy.void, [numpy.record]]]],
numpy.bool_,
numpy.datetime64,
numpy.object_]]
Note
pandas also defines the types ` category ` , and ` datetime64[ns, tz] ` ,
which are not integrated into the normal NumPy hierarchy and wonât show up
with the above function.
[ __ previous Intro to data str... | |
pandas_user_guide/tutorialbasicvectori_36_0.txt | ## Table of Contents | |
pandas_user_guide/vectorizationinpanda_23_0.txt | Data manipulation is a fundamental aspect of data analysis, and it often
involves performing operations on large datasets. Pandas, a popular Python
library for data manipulation, offers a powerful technique called
“vectorization” that allows you to efficiently apply operations to entire
columns or Series of data, elimi... | |
pandas_user_guide/pandas_user_guide_25_16.txt | b'), (0, 'c')])]
Out[183]:
0 c 2
1 a 3
dtype: int64
In [184]: s_mi.iloc[s_mi.index.isin(['a', 'c', 'e'], level=1)]
Out[184]:
0 a 0
c 2
1 a 3
c 5
dtype: int64
DataFrame also has an [ ` isin() `
](../reference/api/pandas.DataFrame.isin.... | |
pandas_user_guide/pandas_user_guide_20_6.txt | #
You may also stack or unstack more than one level at a time by passing a list
of levels, in which case the end result is as if each level in the list were
processed individually.
In [35]: columns = pd.MultiIndex.from_tuples(
....: [
....: ("A", "cat", "long"),
....: ... | |
pandas_user_guide/vectorizationinpanda_115_0.txt | [
](https://medium.com/m/signin?actionUrl=%2F_%2Fapi%2Fsubscriptions%2Fnewsletters%2F3b2c51364ebd&operation=register&redirect=https%3A%2F%2Fpython.plainenglish.io%2Fvectorization-
in-pandas-simplifying-data-
operations-3a4fda08a184&newsletterV3=f319c9e06fc1&newsletterV3Id=3b2c51364ebd&user=Gaurav+Kumar&userId=f319c9e06... | |
pandas_user_guide/vectorizationinpanda_99_0.txt | [
](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Fpython-
in-plain-
english%2F3a4fda08a184&operation=register&redirect=https%3A%2F%2Fpython.plainenglish.io%2Fvectorization-
in-pandas-simplifying-data-
operations-3a4fda08a184&user=Gaurav+Kumar&userId=f319c9e06fc1&source=-----3a4fda08a184
--... | |
pandas_user_guide/pandas_user_guide_26_20.txt | .datetime(2013, 10, 2, 10, 0),
.....: datetime.datetime(2013, 10, 1, 20, 0),
.....: datetime.datetime(2013, 10, 2, 10, 0),
.....: datetime.datetime(2013, 12, 2, 12, 0),
.....: datetime.datetime(2013, 12, 2, 14, 0),
.....: ],
... | |
pandas_user_guide/howtospeeduppythonpa_74_0.txt | #### Access Open Source LLMs Anywhere - Mobile LLMs with Ollama | |
pandas_user_guide/pandas_user_guide_2_24.txt | e: float64
` asfreq ` provides a further convenience so you can specify an interpolation
method for any gaps that may appear after the frequency conversion.
In [289]: ts.asfreq(pd.offsets.BDay(), method="pad")
Out[289]:
2010-01-01 1.494522
2010-01-04 1.494522
2010-01-05 1... | |
pandas_user_guide/vectorizationinpanda_47_0.txt | In this case, we’re using a lambda function to check if each element in ‘A’ is
even or odd and assigning the result to column ‘D’. | |
pandas_user_guide/pandas_user_guide_5_27.txt | y its
values. The [ ` DataFrame.sort_values() `
](../reference/api/pandas.DataFrame.sort_values.html#pandas.DataFrame.sort_values
"pandas.DataFrame.sort_values") method is used to sort a ` DataFrame ` by its
column or row values. The optional ` by ` parameter to [ `
DataFrame.sort_values() `
](../reference/api/pand... | |
pandas_user_guide/pandas_user_guide_2_10.txt | 23:56:00 1.197749
2013-02-27 23:57:00 0.720521
2013-02-27 23:58:00 -0.072718
2013-02-27 23:59:00 -0.681192
2013-02-28 00:00:00 -0.557501
[83521 rows x 1 columns]
We are stopping on the included end-point as it is part of the index:
In [111]: dft["2013-1-15":"2013-1-15 12:... | |
pandas_user_guide/pandas_user_guide_18_15.txt | /stackoverflow.com/questions/20497897/converting-dict-of-dicts-into-
pandas-dataframe-memory-issues)
[ Troubleshoot HDFStore exceptions
](https://stackoverflow.com/questions/15488809/how-to-trouble-shoot-hdfstore-
exception-cannot-find-the-correct-atom-type)
[ Setting min_itemsize with strings
](https://stackoverflow... | |
pandas_user_guide/pandas_user_guide_23_1.txt | D]
[ ` NA ` ](../reference/api/pandas.NA.html#pandas.NA "pandas.NA") for [ `
StringDtype ` ](../reference/api/pandas.StringDtype.html#pandas.StringDtype
"pandas.StringDtype") , [ ` Int64Dtype `
](../reference/api/pandas.Int64Dtype.html#pandas.Int64Dtype
"pandas.Int64Dtype") (and other bit widths), ` Float64Dty... | |
pandas_user_guide/pandas_user_guide_2_29.txt | min, dtype: int64
In [344]: ts.resample("17min", offset="23h30min").sum()
Out[344]:
2000-10-01 23:30:00 9
2000-10-01 23:47:00 21
2000-10-02 00:04:00 54
2000-10-02 00:21:00 24
Freq: 17min, dtype: int64
Note the use of ` 'start' ` for ` origin ` on the last example. ... | |
pandas_user_guide/howtospeeduppythonpa_44_0.txt | %%timeit
df = get_data()
df['reward'] = df.apply(reward_calc, axis=1) | |
pandas_user_guide/pandas_user_guide_26_7.txt | in "pandas.core.groupby.DataFrameGroupBy.min") | Compute the minimum value in each group
[ ` nunique() ` ](../reference/api/pandas.core.groupby.DataFrameGroupBy.nunique.html#pandas.core.groupby.DataFrameGroupBy.nunique "pandas.core.groupby.DataFrameGroupBy.nunique") | Compute the number of unique values in each g... | |
pandas_user_guide/pandas_user_guide_25_30.txt |
* Setting with enlargement conditionally using ` numpy() `
* The ` query() ` Method
* ` MultiIndex ` ` query() ` Syntax
* ` query() ` Use Cases
* ` query() ` Python versus pandas Syntax Comparison
* The ` in ` and ` not in ` operators
* Special use of the ` == ` operator with ` l... | |
pandas_user_guide/pandas_user_guide_7_5.txt | 'auto'.
Whether to register converters with matplotlib's units registry for
dates, times, datetimes, and Periods. Toggling to False will remove
the converters, restoring any converters that pandas overwrote.
[default: auto] [currently: auto]
styler.format.decimal : str
The ch... | |
pandas_user_guide/pandas_user_guide_11_7.txt | nd [ ` DataFrame.query() `
](../reference/api/pandas.DataFrame.query.html#pandas.DataFrame.query
"pandas.DataFrame.query") , this allows you to have a local variable and a [ `
DataFrame ` ](../reference/api/pandas.DataFrame.html#pandas.DataFrame
"pandas.DataFrame") column with the same name in an expression.
... | |
pandas_user_guide/vectorizationinpanda_33_0.txt | # Example 2: Applying Functions | |
pandas_user_guide/pandas_user_guide_18_11.txt | 05/01/aggregation-
timeseries.html)
Turn a matrix with hours in columns and days in rows into a continuous row
sequence in the form of a time series. [ How to rearrange a Python pandas
DataFrame? ](https://stackoverflow.com/questions/15432659/how-to-rearrange-a-
python-pandas-dataframe)
[ Dealing with duplicates when... | |
pandas_user_guide/pandasvectorization_6_0.txt | **Pandas vectorized methods** | |
pandas_user_guide/pandas_user_guide_27_56.txt | A B C
foo bar
baz two -1.646063 -0.695847 -0.429156
If the ` MultiIndex ` levels names are ` None ` , the levels are
automatically made available via the ` level_n ` keyword with ` n ` the
level of the ` MultiIndex ` you want to select from.
... | |
pandas_user_guide/pandas_user_guide_26_12.txt | pandas.core.groupby.DataFrameGroupBy.cumcount "pandas.core.groupby.DataFrameGroupBy.cumcount") | Compute the cumulative count within each group
[ ` cummax() ` ](../reference/api/pandas.core.groupby.DataFrameGroupBy.cummax.html#pandas.core.groupby.DataFrameGroupBy.cummax "pandas.core.groupby.DataFrameGroupBy.cummax... | |
pandas_user_guide/vectorizationinpanda_69_0.txt | import numpy as np
import timeit | |
pandas_user_guide/pandas_user_guide_8_8.txt | l_right": [2, 2, 2]})
In [75]: pd.merge(df1, df2, on="col1", how="outer", indicator=True)
Out[75]:
col1 col_left col_right _merge
0 0 a NaN left_only
1 1 b 2.0 both
2 2 NaN 2.0 right_only
3 2 NaN 2.0... | |
pandas_user_guide/pandasvectorization_11_0.txt |
In [51]: | |
pandas_user_guide/pandas_user_guide_8_5.txt | indexes which must contain unique values.
* **many-to-one** : joining a unique index to one or more columns in a different [ ` DataFrame ` ](../reference/api/pandas.DataFrame.html#pandas.DataFrame "pandas.DataFrame") .
* **many-to-many** : joining columns on columns.
Note
When joining columns on columns, po... | |
pandas_user_guide/howtospeeduppythonpa_168_0.txt | [  |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.