请用易于理解的语言或某篇文章的链接进行解释.
我有一个Dataframe,df,包含以下列:
df['ArrivalDate'] =
...
936 2012-12-31
938 2012-12-29
965 2012-12-31
966 2012-12-31
967 2012-12-31
968 2012-12-31
969 2012-12-31
970 2012-12-29
971 2012-12-31
972 2012-12-29
973 2012-12-29
...
Run Code Online (Sandbox Code Playgroud)
该列的元素是pandas.tslib.Timestamp.
我想要包括年份和月份.我认为会有简单的方法,但我无法弄清楚.
这是我尝试过的:
df['ArrivalDate'].resample('M', how = 'mean')
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Only valid with DatetimeIndex or PeriodIndex
Run Code Online (Sandbox Code Playgroud)
然后我尝试了:
df['ArrivalDate'].apply(lambda(x):x[:-2])
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
'Timestamp' object has no attribute '__getitem__'
Run Code Online (Sandbox Code Playgroud)
有什么建议?
编辑:我有点想通了.
df.index = df['ArrivalDate']
Run Code Online (Sandbox Code Playgroud)
然后,我可以使用索引重新采样另一列.
但我仍然想要一种重新配置整个列的方法.有任何想法吗?
我正在使用Java链接列表,所以我试图掌握单个链表的概念.
head -> 12 -> 34 -> 56 -> null
head.next将是12(也与node1相同).然而,什么是头呢?
更新:引用和指针之间有什么区别?
Update2:所以如果head是12和head.next是34,那么这并不意味着这个跟随函数会跳过第一个节点,看它是否为空?
public void add(Object data, int index)
// post: inserts the specified element at the specified position in this list.
{
Node temp = new Node(data);
Node current = head;
// crawl to the requested index or the last element in the list,
// whichever comes first
for(int i = 1; i < index && current.getNext() != …Run Code Online (Sandbox Code Playgroud) 这是来自https://keras.io/examples/vision/image_classification_from_scratch/的代码
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
# generate a dataset
image_size = (180,180)
batch_size = 32
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
"PetImages",
validation_split = 0.2,
subset = "training",
seed = 1337,
image_size = image_size,
batch_size = batch_size,
)
Run Code Online (Sandbox Code Playgroud)
错误是
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-21-bb7f2d14bf63> in <module>
3 batch_size = 32
4
----> 5 train_ds = tf.keras.preprocessing.image_dataset_from_directory(
6 "PetImages",
7 validation_split = 0.2,
AttributeError: module 'tensorflow.keras.preprocessing' has no attribute 'image_dataset_from_directory'
Run Code Online (Sandbox Code Playgroud)
我现在忽略的任何最小细节?
deep-learning conv-neural-network tensorflow jupyter-notebook
java ×2
extends ×1
implements ×1
inheritance ×1
interface ×1
linked-list ×1
pandas ×1
python ×1
tensorflow ×1