I'm having network traffic data in this location "C:\Users\ASHWIN\Desktop\Test3_pcap.csv". In that file contain frame.number, frame.time, eth.src, eth.dst, ip.src, ip.dst, ip.proto, tcp.stream, tcp.seq, tcp.ack, tcp.window_size and tcp.len which divided in column.
Besides i already declared some importing files in my Ipython notebook which is in below:
from pandas import DataFrame, read_csv
import matplotlib.pyplot as plt
import pandas as pd
import sys
%matplotlib inline
I wanted to do plotting graph for TCP-time sequence graph by using my csv file but its turns alot of error. The sample code i did and get error was as below;
fields=["tcp.stream", "ip.src", "ip.dst", "tcp.seq", "tcp.ack", "tcp.window_size", "tcp.len"]
ts=read_csv("C:\Users\ASHWIN\Desktop\Test3_pcap.csv", fields, timeseries=True, strict=True)
ts
stream=ts[ts["tcp.stream"] == 10]
print stream.to_string()
stream["type"] = stream.apply(lambda x: "client" if x["ip.src"] == stream.irow(0)["ip.src"] else "server", axis=1)
print stream.to_string()
client_stream=stream[stream.type == "client"]
client_stream["tcp.seq"].plot(style="r-o")
When I run all this 8 code through my Ipython notebook it show alot of error. Can anyone solve my problem using this network traffic csv file. I wanted to create a TCP-time sequence graph for this network traffic data in csv format. I'm hoping alot is anyone can solve my problem in this ipython notebook.Thank you.
My code:
from pandas import DataFrame, read_csv
import matplotlib.pyplot as plt
import pandas as pd
import sys
%matplotlib inline
Location = r'C:\Users\ASHWIN\Desktop\tempo\New folderTest3_pcap.csv'
fields=["tcp.stream", "ip.src", "ip.dst", "tcp.seq", "tcp.ack", "tcp.window_size", "tcp.len"]
ts=read_csv(Location, fields, timeseries=True, strict=True)
ts
And this is the error I get:
TypeError Traceback (most recent call last)
<ipython-input-6-ae8455b41c8b> in <module>()
1 Location = r'C:\Users\ASHWIN\Desktop\tempo\New folderTest3_pcap.csv'
2 fields=["tcp.stream", "ip.src", "ip.dst", "tcp.seq", "tcp.ack", "tcp.window_size", "tcp.len"]
----> 3 ts=read_csv(Location, fields, timeseries=True, strict=True)
4 ts
TypeError: parser_f() got an unexpected keyword argument 'timeseries'
timeseries, as well as strict, are not valid arguments of read_csv()
Related
I want to read an excel file into pandas from an AWS S3 bucket. Everything worked fine But when I import PandasCursor, which I need for another part of the code, I receive the following error message:
import pandas as pd
import s3fs
from pyathena import connect
from pyathena.pandas.cursor import PandasCursor
path = "s3://some/path/to/file.xlsx"
df = pd.read_excel(path)
>>>TypeError: S3FileSystem.__init__() missing 1 required positional argument: 'connection'
Can anyone explain what is happening and how I can fix it?
From the pyathena docs I don't understand how PandasCursor is influencing pd.read_excel()
hope someone can help me,
I'm trying to run the adfuller test, but it return me error:'NoneType' object is not callable, the excel file should be well imported and no needed to drop Nan.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.stattools import adfuller
bond_future_data=pd.read_excel('europe_market_data.xlsx', sheet_name='RXA',header=[0],index_col=[0])
bond_future_data.columns.names=['car']
bond_future_data.index.names=['dates']
bond_future_price=bond_future_data['RX1 Comdty']
adfuller(bond_future_price)
I thought that was an error in the way I imported adfuller, but shouldn't be cause the following code works
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.stattools import adfuller
a=np.linspace(0,10)
print(adfuller(a))
this is the error:
Exception has occurred: TypeError
'NoneType' object is not callable
File "/Users/federicoruggieri/Desktop/phyton/#garch and imp vol.py", line 25, in
adfuller(bond_future_price)
i also add a screenshot where I printed the dataframe.
screen of printed dataframe
I have been trying to use the pvlib-python tool for forecasting. The tool comes with some model-specific classes.
# Import pvlib forecast models
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime
import seaborn as sns; sns.set_color_codes()
from pvlib.forecast import GFS, NAM, NDFD, HRRR, RAP
from pvlib import solarposition
# Specify Location (Phoenix, AZ)
latitude, longitude, tz = 32.2, -110.9, 'US/Arizona'
# Specify time range
start = pd.Timestamp(datetime.date.today(), tz=tz)
end = start + pd.Timedelta(days=7)
irrad_vars = ['ghi','dni','dhi']
from pvlib.forecast import GFS, NAM, NDFD, HRRR, RAP
model = GFS()
# Retrive data.returns panda.DataFrame object
raw_data = model.get_data(latitude, longitude, start, end)
print(raw_data.head())
When I try to get data from the model, the code produces the following output:
TypeError Traceback (most recent call last)
# Retrive data.returns panda.DataFrame object
----> 6 raw_data = model.get_data(latitude, longitude, start, end)
TypeError: <class 'cftime._cftime.DatetimeGregorian'> is not convertible to datetime
So i don't know what is in your getdata function but i would suspect it uses netCDF4 library. and the netCDF4.num2date function which is built on the cftime library (https://github.com/Unidata/cftime). See requirements section of netCDF4 documentation: https://unidata.github.io/netcdf4-python/netCDF4/index.html
It seems they migrated away from python datetime library around version 5 because it can handle more calendars than strictly gregorian. I don't totally understand why, but you can use the kwarg options of only_use_cftime_datetimes=False usually will suffice, but you can also force it with an additional only_use_python_datetimes=True This should return you a python datetime and fix your problem.
It was discussed by pvlib's contributors here: https://github.com/pvlib/pvlib-python/issues/944
One of the suggestions was downgrading cftime and it worked for me.
I would like to use the pandas package for python. Some functionalities work, but when I try to pass "include" argument into the describe() function I get an error:
train_df.describe(include=['O'])
Full code looks like thie following:
import numpy as np
import pandas as pd
import random as rnd
import matplotlib.pyplot as plt
# aquire data
train_df = pd.read_csv('train.csv')
test_df = pd.read_csv('test.csv')
train_df.describe(include=['O'])
I get the following error:
>> python survival.py
Traceback (most recent call last):
File "survival.py", line 10, in <module>
train_df.describe(include=['O'])
TypeError: describe() got an unexpected keyword argument 'include'
Using the .describe() on its own seems to work. Any ideas? Thank you.
I was attempting to follow a pandas/sklearn/kaggle tutorial, and barely got a dozen lines when I stumbled over over one of the simplest commands in python:
Code:
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
pd.options.display.max_columns = 100
pd.options.display.max_rows = 100
import matplotlib as mpl
import matplotlib.pyplot as pd
import numpy as np
#Cell 3
data = pd.read_csv('./Data/train.csv')
data.head()
Error:
Traceback (most recent call last):
File "KaggleTitanic00.py", line 15, in <module>
data = pd.read_csv('./Data/train.csv')
AttributeError: 'module' object has no attribute 'read_csv'
A command that only gives an error in that directory:
~/Python/Tutorials/SKlearn$ python Chapter4--Test-12.py
Number of spam messages: 747
Number of ham messages: 4825
['spam' 'spam' 'ham' ..., 'ham' 'ham' 'ham']
Prediction: spam. Message: Ur cash-balance is currently 500 pounds - to maximize ur cash-in now send GO to 86688 only 150p/msg. CC 08718720201 HG/Suite342/2Lands Row/W1J6HL
Prediction: spam. Message: December only! Had your mobile 11mths+? You are entitled to update to the latest colour camera mobile for Free! Call The Mobile Update Co FREE on 08002986906
Prediction: ham. Message: Just normal only here :)
Prediction: ham. Message: How would my ip address test that considering my computer isn't a minecraft server
Prediction: ham. Message: Ü collecting ur laptop then going to configure da settings izzit?
I have absolutely no idea what's wrong. The code is identical to the tutorial.
Write:
import matplotlib.pyplot as plt
By reimporting as pd you overwrite import pandas as pd