Не могли бы вы помочь мне решить эту ошибку, пожалуйста?
Я пытаюсь выполнить следующий код, чтобы сохранить DataFrame локально как разделяемый файл Parquet:
dfcitas.write.format("parquet")\
.mode("overwrite")\
.partitionBy("NPatente")\
.save("/datos/dfcitas-particionado.parquet")
И эта ошибка появляется:
AttributeErrorTraceback (most recent call last)
<ipython-input-164-9b06b4833bf9> in <module>()
----> 1 dfcitas.write.format("parquet") .mode("overwrite") .partitionBy("NPatente") .save("/datos/dfcitas-particionado.parquet")
/opt/conda/lib/python2.7/site-packages/pandas/core/generic.pyc in __getattr__(self, name)
3612 if name in self._info_axis:
3613 return self[name]
-> 3614 return object.__getattribute__(self, name)
3615
3616 def __setattr__(self, name, value):
AttributeError: 'DataFrame' object has no attribute 'write'
DataFrame, над которым я работаю, имеет следующие 2 столбца:
- NPatente
- ncitas
Я запускаю код на dockerized Zeppelin и создаю dfcitas DataFrame, используя следующий код:
# Importing the Pandas library
import pandas as pd
# Reading the cite75_99.txt.bz2 file in compressed format and sabing it to a DataFrame
df = pd.read_csv('/datos/cite75_99.txt.bz2', compression='bz2', header=0, sep=',', quotechar='"')
# Grouping the number of patents and counting the numbre of cites that each patent recieved in a new DataFrame
dfcitas = df.groupby('CITING')['CITED'].count().reset_index()
# Renaming the columns of the new DataFrame
dfcitas.columns = ['NPatente','ncitas']
# Printng the DataFrame
print(dfcitas)
Ваша помощь здесь приветствуется.
Спасибо!